Unicode文本转换
在浏览器中把每个UTF-16代码单元编码成JavaScript风格的四位\uXXXX转义,支持十六进制a—f大小写;也可严格解码嵌在普通文本中的四位转义,并定位残缺或非十六进制的反斜杠-u序列。输入最多100,000个UTF-16字符,编码输出最多500,000字符,支持复制与TXT下载。
使用步骤
如何使用
- Choose text-to-escapes or escapes-to-text and enter up to 100,000 UTF-16 characters.
- For encoding, choose lowercase or uppercase hexadecimal digits; for decoding, correct any identified malformed escape.
- Convert locally, review the exact result, then copy it or download a text file.
Four hexadecimal digits per UTF-16 unit
Encoding emits one lowercase \u followed by exactly four hexadecimal digits for every browser UTF-16 code unit, including ASCII letters, spaces, punctuation, and line breaks. Choose lowercase or uppercase hexadecimal letters. Supplementary characters such as many emoji use two surrogate code units and become two adjacent escapes. This matches JavaScript \uXXXX string-literal units; it does not emit code-point braces such as \u{1F44B}.
Strict decoding with visible failures
Decoding replaces every exact lowercase-u \uXXXX sequence, including sequences embedded in ordinary text. A backslash-u prefix without four following hexadecimal digits stops with its UTF-16 position instead of being silently retained. Other text and backslash sequences remain unchanged. Isolated surrogate escapes are preserved as the exact UTF-16 code units they represent, so callers that require Unicode scalar values should supply paired surrogates.
常见问题
你可能还想知道
Why does one emoji become two escapes?
The browser stores supplementary Unicode characters as a UTF-16 surrogate pair. This converter intentionally emits one four-digit escape per UTF-16 code unit.
Does decoding require the entire input to be escaped?
No. Exact \uXXXX sequences can appear inside ordinary text; only those sequences are replaced. Other text remains in place.
Does this support \u{1F44B} or \x48?
No. The scope is the classic four-digit lowercase-u form \uXXXX. Braced code-point and two-digit byte escape syntaxes are outside this converter.