How do i use 32 bit unicode characters in C#?
Maybe i don开发者_JAVA技巧t need 32bit strings but i need to represent 32bit characters
http://www.fileformat.info/info/unicode/char/1f4a9/index.htm Now i grabbed the symbola font and can see the character when i paste it (in the url or any text areas) so i know i have the font support for it.
But how do i support it in my C#/.NET app?
-edit- i'll add something. When i pasted the said character in my .NET winform app i DO NOT see the character correctly. When pasting it into firefox i do see it correctly. How do i see the characters correctly in my winform apps?
I am not sure I understand your question:
String
s in .NET are UTF-16 encoded, and there is nothing you can do about this. If you want to get the UTF-32 version of a string, you will have to convert it into a byte array with the UTF32Encoding class.Char
acters in .NET are thus 16 bits long, and there is nothing you can do about this either. A UTF-32 encoded character can only be represented by a byte array (with 4 items). You can use the UTF32Encoding class for this purpose.- Every UTF-32 character has an equivalent UTF-16 representation, and vice-versa. So in this context we could only speak of characters, and of their different representations (encodings), UTF-16 being the representation of choice on the .NET platform.
You didn't say what exactly do you mean by “support”. But there is nothing special you need to do to to work with characters that don't fit into one 16-bit char
, unless you do string manipulation. They will just be represented as surrogate pairs, but you shouldn't need to know about that if you treat the string
as a whole.
One exception is that some string manipulation methods won't work correctly. For example "\U0001F4A9".Substring(1)
will return the second half of the surrogate pair, which is not a valid string.
If the question is actually,
How do I put the 'pile of poo' emoji, U+1F4A9, into a C# string literal, given that it needs 32 bits to represent in a UTF-16 code page?
then the answer is:
"\U0001F4A9"
In the C# Interactive window in Visual Studio this shows the following output:
上一篇:代理价格钱打给上家什么意思?
下一篇:在杀人现场是什么罪?
最新问答
-
央视是哪个频道?
央视是哪个频道西非利 33分钟前 来自北京1、央视一共有15个频道,分别是:CCTV-1综合频道、CCTV-2财经频道、CCTV-3综艺频道、CCTV-4中文国际频道、CCTV-5体育频道、CCTV-6电影频道、CCTV-7军事·农业频道、CC
-
请问买过的朋友,舒提啦旅行箱实际使用体验如何??
请问买过的朋友,舒提啦旅行箱实际使用体验如何?
-
检查不孕不育需要的费用?
检查不孕不育需要的费用 补充说明:检查不孕不育需要的费用霸气御姐←_← 12小时前
-
海信ULED电视画质有什么不同的地方??
海信ULED电视画质有什么不同的地方?樊倩竹 1天前 来自北京海信ULED电视按照我的理解,就是不同的面板技术,一般来说,ULED有背光,可以实现分区背光;QLED有背光,属于背光灯上覆盖量子膜;OLED无背光,属于自
-
钉子可以挂的住画框幕布吗?
钉子可以挂的住画框幕布吗360U3082033870 1天前 来自湖北可以。1、厚重的画框幕布挂在墙上的话,你可以给他钉一台钉子,这样的话他可以挂在后面的墙上,相对来说也是比较结实的。2、所以钉子可以挂的住画框幕
问答排行榜
-
王昌瑞《潜梦追凶》剧组庆生 新锐演员未来可期?
103010正在紧张有序的拍摄中,恰逢演员王昌瑞的生日。现场工作人员为他庆生,主演也送上祝福。
-
Is it allowed to ask users to enter credit card details for own payment method?
It seems to me Apple won\'t allow this, but I need to make sure. For an app we\'re building, we want to ask the user to enter payment information (including credit card details) to pay for tickets. T
-
Escaping "<" in Perl-generated XML
I need to generate an XML output using Perl code.I\'m trying not to use any libraries,as it\'s very simple, temporary XML that gets used by another step in the process.
-
imessage会显示已读吗?
是否在对方手机上显示已读,是由用户自行设置的。依次打开iPhone的“设置-信息”,会有一个“发送已读回执”的选项。将其打开,对方就能看到你,是否已经阅读了本条iMessage信息。将其关闭,对方就看不到。
-
微信重新建群怎么建?
微信重新建群怎么开发者_Go百科建? 产品名称:苹果手机 产品型号:iPhone 11 系统版本:iOS 13
精彩评论