Skip to content
UniKit

UTF-8 Chinese converter

Convert Chinese text to UTF-8 bytes as hex, percent-encoding (%E4%B8%AD), \xHH, \uXXXX escapes or a decimal byte array, and decode those forms back. Invalid, truncated and overlong UTF-8 is reported with a precise RFC 3629 error.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Chinese text or byte representation

encode: Chinese text to UTF-8 bytes; decode: auto-detects hex, percent, \xHH, \uXXXX and decimal byte lists.

Conversion result

UTF-8 is encoded and decoded in-house per RFC 3629, without TextEncoder; "characters" counts code points, a surrogate pair counts as one.

Enter something to see the conversion

What this tool does

  • Turn Chinese parameters, filenames or form values into UTF-8 hex for code, configs and mojibake debugging
  • Get all five representations of one text at once: E4 B8 AD, %E4%B8%AD, \xE4\xB8\xAD, \u4E2D and decimal bytes 228 184 173
  • Decode byte strings from logs, packet captures or databases back to Chinese, with a precise reason when the bytes are invalid or truncated

Example

Input

中文

Output

E4 B8 AD E6 96 87

Default direction is "Chinese → UTF-8 bytes" with the hex representation; one Chinese character is 3 bytes, so 中文 is 6 bytes.

Frequently asked questions

Is \u4E2D the same as the UTF-8 bytes?

No. \u4E2D is an escape for the code point written as UTF-16 code units (one escape per character), while UTF-8 bytes are the bytes actually stored in a file or sent over the network. Astral characters differ even more: 😀 (U+1F600) is \uD83D\uDE00 as a surrogate pair but F0 9F 98 80 as four UTF-8 bytes. This tool shows both, but they live on different levels.

Which bytes are treated as invalid?

Four RFC 3629 violations get distinct error codes: truncated (E4 B8), overlong encoding (C0 AF), surrogate range (ED A0 80) and above U+10FFFF (F4 90 80 80), plus invalid leading or continuation bytes (80, FF, E4 41). Errors are raised by default instead of being replaced; enable "Replace invalid bytes with U+FFFD" to get one U+FFFD per offending byte.

How does decode auto-detection work?

It checks %HH, then \xHH, then \uXXXX, then a plain hex string, then a decimal byte list; when nothing matches it treats the input as already-decoded text and returns it with its UTF-8 bytes. So a short string made only of hex characters such as ABC is treated as hex (and fails on odd length) — pick the "Already text" input format in that case.

Why not use TextEncoder / TextDecoder?

Two reasons: identical results in node and in the browser (the unit tests run in node), and TextDecoder can only turn invalid bytes into U+FFFD without telling truncated, overlong, surrogate and out-of-range apart. The codec here is implemented per RFC 3629, so each violation gets its own error code.

Does it handle emoji and non-Chinese text?

Yes, it is a UTF-8 codec for any character. In the stats, "characters" counts code points (😀 counts as 1), "UTF-16 code units" follows the JS string length (😀 is 2) and "bytes" is the UTF-8 length (😀 is 4).

Keywords:UTF8转中文中文转UTF8UTF-8 编码百分号编码URL 编码Unicode 转义\u4E2DUTF-8 hexunicode escapeutf8 decode

Related tools