如何在C#中使用32位unicode字符? [英] How do i use 32 bit unicode characters in C#?

查看:388
本文介绍了如何在C#中使用32位unicode字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许我不需要32位字符串,但我需要表示32位字符

Maybe i dont need 32bit strings but i need to represent 32bit characters

http://www.fileformat.info/info/unicode/char/1f4a9/index.htm
现在,我抓住了symbola字体和当我将其粘贴(在url或任何文本区域中)时可以看到该字符,因此我知道我对此有字体支持。

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.

但是我如何在其中支持它我的C#/。NET应用程序?

But how do i support it in my C#/.NET app?

-编辑-我要添加一些内容。当我在.NET winform应用程序中粘贴上述字符时,我看不到正确的字符。当将其粘贴到Firefox中时,我确实可以正确看到它。我如何在我的Winform应用程序中正确看到字符?

-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是UTF-16编码的,您无能为力这个。如果要获取字符串的UTF-32版本,则必须使用 UTF32Encoding 类。

  • 。NET中的 Char 角色长16位,因此您无能为力这要么。 UTF-32编码的字符只能由字节数组(包含4个项)表示。为此,您可以使用 UTF32Encoding 类。

  • 每个UTF-32字符都具有等效的UTF-16表示形式,反之亦然。因此,在这种情况下,我们只能说字符以及它们的不同表示形式(编码),UTF-16是.NET平台上的选择表示形式。

  • Strings 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.
  • Characters 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.

这篇关于如何在C#中使用32位unicode字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆