gpt4 book ai didi

c# - 将十六进制 UTF-8 字节转换为十六进制代码点

转载 作者:太空狗 更新时间:2023-10-29 23:10:14 25 4
gpt4 key购买 nike

我怎样才能转换
十六进制 UTF-8 字节 -E0 A4 A4 到十六进制代码点 - 0924

引用:http://www.ltg.ed.ac.uk/~richard/utf-8.cgi?input=e0+a4+a4&mode=bytes

我需要这个,因为当我在 C# 中读取 Unicode 数据时,它把它当作单字节序列并显示 3 个字符而不是 1,但我需要 3 个字节序列(读取 3 个字节并显示单个字符),我尝试了很多解决方案但没有得到结果。

如果我可以显示或存储一个 3 字节序列的 utf-8 字符,那么我不需要转换。

senario是这样的:

    string str=getivrresult();

在 str 中,我有一个单词,每个字符都是 3 字节的 utf-8 序列。

编辑:

             string str="त";
//i want it as "त" in str.

Character त
Character name DEVANAGARI LETTER TA
Hex code point 0924
Decimal code point 2340
Hex UTF-8 bytes E0 A4 A4
Octal UTF-8 bytes 340 244 244
UTF-8 bytes as Latin-1 characters bytes à ¤ ¤

谢谢。

最佳答案

Encoding类中使用GetString方法:

byte[] data = { 0xE0, 0xA4, 0xA4 };
string str = Encoding.UTF8.GetString(data);

该字符串现在包含一个字符代码为 0x924 的字符。

关于c# - 将十六进制 UTF-8 字节转换为十六进制代码点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7727377/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com