Reputation: 1593
I am getting this weird occurrence when using unicodes in my application. I have a list of random unicodes which I then randomly assign to an object.
var icons = new List<string> { "\uf022", "\uf039", "\uf02b", "\uf1b2", "\uf07b" };
When I debug the object the Object.Icon
property shows "."
which is the correct value for unicode. When I display the unicodes on a XAML page the correct icons are displayed.
So when I got this working I wanted to move the unicode values into the database instead of making it random. But now when I debug the object the Object.Icon
property shows "\\unicodevalue"
i.e "\uf022".
When displaying this value on the XAML page, its being displayed as the text value \uf022 instead of an icon.
What is the difference between the strings in the icons list and having the string value in the database?
Upvotes: 0
Views: 1212
Reputation: 271410
The unicode sequences in the database have their backslash escaped, so "\\uf042"
is really 6 characters altogether: the backslash, "u", "f", "0", "4" and "2".
The unicode sequences in your code however, are really just one character as far as C# is concerned, They are literals of unicode code points.
To change from the values in your database to individual unicode code points, try the Char.ConvertFromUtf32
method.
Upvotes: 2