0

I am trying to implement chat functionality in WP8.0. Whenever I receive a smiley from the server. It does not display correctly in the UI. This is the code
`

 public string Comment
  {
   get
   { return _comment; }
   set
   {
    if (value != null)
    {
       // value I am trying to convert is "Testing smileys \\uD83D\\uDE03\\uDE03"
       string convertedCharacter = System.Text.RegularExpressions.Regex.Unescape(value);
       _comment = convertedCharacter;
    }
}
}

`

  • What *exactly* do you mean by "I am unable to do the conversion"? What conversion? What does your code look like? What happens? I'm afraid at the moment your question is too unclear to answer. – Jon Skeet Apr 14 '16 at 13:30
  • The character \u263A resembles a smiley. When I display it on textblock it appears as \u263a and not a smiley. How to convert it to smiley. I am unable to understand how to convert \u263a to a smiley – Rosita Clerissa Serrao Apr 14 '16 at 13:32
  • We have no idea how you're communicating or what *any* of your code looks like. There's no way we can help you with so little information, I'm afraid. – Jon Skeet Apr 14 '16 at 13:37
  • Thank you for taking time to reply. How do we display the unicode smileys? I am trying this for converting unicode to respective smiley. byte[] uni = Encoding.UTF8.GetBytes(value); string convertedstring= Encoding.Unicode.GetString(uni, 0, uni.Length); However this is not working fine – Rosita Clerissa Serrao Apr 14 '16 at 14:00
  • Please put the code *in your question* - and tell us what `value` is. Again, we have no idea how your app is communicating, or basically *anything*. If your app is currently displaying `\u263A` that suggests that maybe something is using JSON and you should be using a JSON parser, for example. But at the moment, we just can't tell. – Jon Skeet Apr 14 '16 at 14:28
  • I have updated the code – Rosita Clerissa Serrao Apr 15 '16 at 05:59
  • So where did that value come from, and why are you trying to use regular expression unescaping? What's performing the escaping, and what else is it escaping? Why are you unescaping in a setter but not escaping in a getter? – Jon Skeet Apr 15 '16 at 06:17
  • I am getting the value from server. I am trying to convert the unicode characters. I referred this link http://stackoverflow.com/questions/1615559/converting-unicode-strings-to-escaped-ascii-string. I am setting it in setter because while receiving the data If I perform conversions. I neednt perform it in getter – Rosita Clerissa Serrao Apr 15 '16 at 07:32
  • What server though? What's the specification for what it will return? Might it use `\Uxxxxxxxx` for non-BMP characters, for example? I'm afraid I give up on this question - we shouldn't have to work this hard for every gradual tiny *bit* of information. (As for the getter/setter part - it's really weird if `foo.Value = foo.Value;` makes a change - which it might in our case. The property should either represent the encoded value, or the non-encoded value - not half and half.) – Jon Skeet Apr 15 '16 at 08:03
  • Thank you for giving your insights. Though I provided with very little info. There were additional characters getting appended. I removed them. Its working fine now. – Rosita Clerissa Serrao Apr 21 '16 at 07:09

1 Answers1

0

To use the smiley face symbol in XAML you can use ☺

e.g.

<TextBlock>&#x263A;</TextBlock>
Glen Thomas
  • 10,190
  • 5
  • 33
  • 65