In my code-behind, I'm trying to return the hexcode for a unicode character.
I'm trying to output any one of these characters for the Segoe UI Symbol font: http://www.istartedsomething.com/uploads/emojisegoe.html . For example, "U+1F60A".
If I do so via my xaml, such as:
FontFamily="Segoe UI Symbol" Text="😊"
Then it works fine.
But if I bind the value to retrieve it via a .cs converter class, the correct character doesn't appear:
FontFamily="Segoe UI Symbol" Text="{Binding Pivot7Days.EmojiWeekendSummary, Converter={StaticResource EmoticonConverter}}"
Converter class:
switch (input)
{
case "happy":
return "\u1F60A";
case "sad":
return "\u1F60B";
default:
return "\u1F610";
}
I get an entirely different character followed by the final character in the returned string, such as 'A', 'B' or '0'. For example, when I should be seeing a face with tongue out (U+1F60B), I instead get the following:
Am I using the incorrect escape sequence in my code behind?
超出U + FFFF的字符不能直接写成\\u....
文字(如果你试过,只使用前四个十六进制数字,你得到一个错误的字符)但是作为代理对,或者更容易,使用8位\\U
字面,例如U + 1F60A的'\\U0001F60A'
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.