将汉字转换成Unicode [英] Converting chinese character to Unicode

查看:167
本文介绍了将汉字转换成Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个随机的汉字玩。我想将其转换为Unicode,这将是U + 73A9。如何在C#中执行此操作?

解决方案

myChar 一个引用你的特殊字符的字符...

  Console.WriteLine({0} U + {1:x4} {2} ,myChar,(int)myChar,(int)myChar); 

以上我们输出的字符本身后跟Unicode代码点,然后是整数值。



减少格式字符串和参数以仅输出U + ...代码...

  Console.WriteLine(U + {0:x4},(int)myChar); 


Let's say I have a random Chinese character, 玩. I want to convert it to Unicode, which would be U+73A9. How could I do this in C#?

解决方案

Take myChar as a char referencing your special character...

Console.WriteLine("{0} U+{1:x4} {2}", myChar, (int)myChar, (int)myChar);

Above we're outputting the character itself followed by the Unicode code point and then the integer value.

Reduce the format string and parameters to output only the "U+..." code...

Console.WriteLine("U+{0:x4}", (int)myChar);

这篇关于将汉字转换成Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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