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、所以钉子可以挂的住画框幕
问答排行榜
-
河神2九牛入海钓河妖是第几集 河妖什么来历可活吞牛?
《河神2》里最震撼的应该是九牛入海钓河妖的画面,把九头牛拴上铁链放入河中,然后引河妖出现,大家再齐心协力抓住它,可惜河妖行踪不定,力大无穷,人们根本不是它的对手。
-
性激素六项检查的最佳时间是多久?多少钱??
对您的评价:真形象啊! 2021-07-04 10:53 检查性激素六项一般是因为内分泌失调开发者_如何学C,月经不正常,闭经等等问题。一般情况下,性激素六项的费用是2~3百元左右。不同级别的医院,收费都有点差别。一般
-
Easiest way to get words of one line from istream into a vector?
istream has the >> operator, but it skips new lines like it skips whitespace. How can I get a list of all the words in 1 line only, into a vector (or anything else that\'s convenien开发者_运维技
-
《梦在燃烧 (《三国演义》动画片主题曲)》MP3歌词-汤子星?
梦在燃烧 (《三国演义》动画片主题曲) 汤子星 语种:国语 本歌词于吾爱知道收集
-
抽烟只抽炫赫门?
抽烟只抽炫赫门作词:匿名作曲:MC烁宝演唱:MC烁宝抽烟只开发者_运维百科抽煊赫门一生只爱一个人为你关了我心门香烟陪我到凌晨是我刚好遇见你把你写进我心底多少心愿为你许独奏这首相思曲余生还有那么长我已收起了锋
精彩评论