Reputation: 455
I have a textblock that is bound to my 'PostContent' string, like so:
<TextBlock TextWrapping="Wrap" TextAlignment="Left" Text="{Binding Path = PostContent, Mode = OneWay}" FontSize="12" Width="300" Margin = "3 5 3 5"/>
My PostContent string will sometimes contain emojis, as well as text. For example I might return a string that looks liks this:
Hello World
😀
However, the textblock displays the literal string, and does not escape the emoji. I've also tried to escape it like this:
Hello World \u1F600
But I still end up having the same problem.
Is there another way to escape these chracters properly?
Upvotes: 0
Views: 210
Reputation: 455
I managed to make this work by taking the hex code (i.e. 1F600) and converting it to a decimal code using the following code:
int result = int.Parse(hexCode, System.Globalization.NumberStyles.HexNumber);
outputString += char.ConvertFromUtf32(result);
Upvotes: 1