Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert Hex UTF-8 bytes to Hex code point

how can i convert
Hex UTF-8 bytes -E0 A4 A4 to hex code point - 0924

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

I need this because when i read Unicode data in c# it is taking it as single byte sequence and displaying 3 characters instead of 1,but i need 3 byte sequence(read 3 bytes and display single character),I tried many solutions but didn't get the result.

If I can display or store a 3-byte sequence utf-8 character then I don't need conversion.

senario is like this:

    string str=getivrresult();

in str I have a word with each character as 3 byte utf-8 sequence.

Edited:

             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     à ¤ ¤  

Thank You.

like image 442
Lalitya Avatar asked Oct 11 '11 14:10

Lalitya


People also ask

How to convert hexadecimal to UTF-8?

Enter bytes of UTF-8, represented in hexadecimal, to get the corresponding Unicode code point. Enter a hexadecimal Unicode code point, in free format, and it will be converted into the corresponding UTF-8 bytes. For users who need to decipher errors, this converter passes through surrogates (Unicode code points from U+D800 to U+DFFF).

How to construct utf8-encoded characters from code point values?

This online tool constructs UTF8-encoded characters from the given code point values. The Unicode standard defines code points (also known as code positions) as numeric values that are uniquely assigned to every possible character. To construct UTF8-encoded characters from the input code points, you must specify the numeric base of the code points.

What is the maximum number of bytes in a UTF-8 converter?

The code point to UTF-8 converter displays the UTF-8 bytes corresponding to values up to this maximum value for four bytes, but it does not allow values resulting in more than four bytes of UTF-8 output. It will only process up to six hexadecimal digits.

How to convert hex values to hexadecimal numbers?

Use Two Digits per Hex Value If hex value is a single digit, append a 0 before it, so that it's two digits. You can pass input to this tool via ?input query argument and it will automatically compute output. Here's how to type it in your browser's address bar. Click to try! Quickly convert ASCII characters to hexadecimal numbers.


1 Answers

Use the GetString methdod in the Encoding class:

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

The string now contains one character with the character code 0x924.

like image 160
Guffa Avatar answered Oct 23 '22 03:10

Guffa