动态生成8位Unicode字符 [英] Dynamic generate 8-Digit-Unicode to Character

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

问题描述

我将动态显示Unicode,

I am going to display Unicode dynamically,

例如,我知道"\ U00020001" 将显示一个字符.(下面的变量"standard_format").但是,我只能直接显示整个字符串("\ U00020001" ).

For example, I know "\U00020001" will display a character. (variable "standard_format" below). However, I can only show the whole string directly ("\U00020001").

我想知道如何将字符串显示为字符.

I would like to know how can I show that string into a character.

推荐答案

如果编写"\ U0002B695" ,则整个字符串将被识别为转义序列.在"\\ U0002B695" 中,只有 \\ 被识别为 \ 的转义序列.我不知道有什么方法可以像编译器那样以这种方式构建字符串文字,然后对其进行解析.

If you write "\U0002B695" the whole string will be recognized as an escape sequence. In "\\U0002B695" however only \\ will be recognized as an escape sequence for \. I don't know a way to build a string literal this way and then parse it like the compiler would do.

为了获取字符串,您需要将十六进制值转换为int,然后将其转换为字符串:

In order to get the string you need to convert the hexadecimal value into an int and then convert that to a string:

string txt_unicodePoint = "2B695";

int value = int.Parse(txt_unicodePoint, System.Globalization.NumberStyles.HexNumber);
string result = char.ConvertFromUtf32(value).ToString();

这篇关于动态生成8位Unicode字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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