简体   繁体   English

Unicode 符号未在推送通知中呈现

[英]Unicode symbol not rendering in Push Notification

I have a number of string literals in my C# that include unicode characters.我的 C# 中有许多字符串文字,其中包含 unicode 个字符。 We are using these to send Push Notifications via Azure Notifcations Hub.我们正在使用这些通过 Azure 通知中心发送推送通知。

When I send one of the strings in this first set below the notification renders with the expected text and emoticon.当我发送下面第一组中的一个字符串时,通知会呈现预期的文本和表情符号。

  • "⚡ Hello, ⚡". “⚡你好,⚡”。 "Hello world." “你好世界。”
  • "Ready to record? ?", "Let's do this!" “准备好录制了吗??”,“让我们开始吧!”
  • "? Got anything?", "We'd love to hear from you." “? 有什么消息吗?”,“我们很想听听您的意见。”

Any of the ones in the set below do appear as Push Notifcations but the special symbols, green circle, amber circle and red circle do not.以下集合中的任何一个都显示为推送通知,但特殊符号、绿色圆圈、琥珀色圆圈和红色圆圈不会。 I'll try and grab a screen shot and reedit this我会尝试抓取屏幕截图并重新编辑

  • "Signal Update", "Signal turned Red. ὓ4 Tap for more." “信号更新”、“信号变红。ὓ4 点击查看更多。” "Signal “信号
  • "Update", "Signal is Green. ὾2 Tap for more." “更新”、“信号为绿色。὾2 点击查看更多。” "Signal Active", “信号激活”,
  • "Signal is Green. ὾2 Tap for more." “信号为绿色。὾2 点击更多。”

I notice that VS 2022 does not fully highlight the escaped unicode strings that do not work and they all have an escape sequence length greater than 5 chars but that fact is likely a red herring.我注意到 VS 2022 没有完全突出显示不起作用的转义 unicode 字符串,它们的转义序列长度都大于 5 个字符,但这个事实很可能是转移注意力。 Here is the VS2022 rendering这是VS2022渲染

在此处输入图像描述

Note the text "...Amber, ὾1 Tap for more".请注意文本“...琥珀色,὾1 点击更多”。 This is how that is rendered in a Push Notification这是在推送通知中呈现的方式

在此处输入图像描述

Note the "1" after the supposed symbol注意假定符号后的“1”

The reason that my unicode characters were not displaying correctly was that I was not escaping them properly in the C# string literal.我的 unicode 个字符没有正确显示的原因是我没有在 C# 字符串文字中正确显示它们 escaping。

26A1 is an example of the strings that were displaying correctly. 26A1是正确显示的字符串示例。 This string is from the UTF16 range and can be escaped with the escape sequence starting "\u", note the lower case "u".该字符串来自 UTF16 范围,可以使用以“\u”开头的转义序列进行转义,注意小写“u”。

1F7E2 is an example of the strings that were not displaying correctly. 1F7E2是未正确显示的字符串示例。 I naively copied the earlier escape sequence and just changed the characters to be escaped.我天真地复制了早期的转义序列,只是改变了要转义的字符。 However this unicode string is from the UTF32 range and needs a different escape sequence, the uppercase u, "\U" making the string literal " Signal is Green. \U0001F7E2 Tap for more. " Note the leading zeroes too.然而,这个 unicode 字符串来自 UTF32 范围,需要不同的转义序列,大写的 u,“\U”使字符串文字“ Signal is Green. \U0001F7E2 Tap for more. ”还要注意前导零。

References that I found useful were我发现有用的参考资料是

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM