Unicode 中文互转Unicode Converter
Unicode编码与中文字符互相转换Convert between Unicode escapes and Chinese characters.
关于 Unicode 中文互转About Unicode Converter
在 Java properties 文件、JavaScript 字符串或某些老旧系统中,中文常被写成 \uXXXX 形式的转义序列。本工具支持 Unicode 转义与中文(及其他字符)双向互转,解决配置乱码与代码可读性问题。In Java properties files, JavaScript strings and some legacy systems, Chinese is often written as \uXXXX escape sequences. This tool converts between Unicode escapes and Chinese (or any other characters) in both directions, fixing config mojibake and readability problems.
使用方法How to Use
- 粘贴含 \uXXXX 转义的文本,点击「Unicode 转中文」得到可读原文。Paste text containing \uXXXX escapes and click "Unicode to text" to get the readable original.
- 或输入中文,点击「中文转 Unicode」得到转义形式。Or type Chinese and click "Text to Unicode" to get the escaped form.
- 工具自动识别四位十六进制转义,并正确处理 Emoji 等代理对字符。The tool recognises four-hex-digit escapes automatically and handles surrogate-pair characters such as Emoji correctly.
常见问题FAQ
Unicode 转义主要用在哪些场景?Where are Unicode escapes mainly used?
Java properties 文件(默认 ISO-8859-1 读取)、部分 JS 代码生成场景、以及不支持 UTF-8 的老旧系统,用转义可以避免编码不一致导致的乱码。Java properties files (read as ISO-8859-1 by default), some JS code-generation scenarios, and legacy systems without UTF-8 support — escapes avoid mojibake from encoding mismatches.
为什么 Emoji 转出来是两个 \u?Why does an Emoji become two \u sequences?
Emoji 等超出基本多文种平面的字符使用 UTF-16 代理对表示,因此会生成一对 \u 转义,这是标准行为,工具会自动成对处理。Characters beyond the Basic Multilingual Plane, like Emoji, use UTF-16 surrogate pairs, so they produce a pair of \u escapes. This is standard behaviour and the tool handles pairs automatically.
转换结果不对怎么排查?How do I troubleshoot wrong results?
检查转义是否为完整的四位十六进制(\u4f60 而非 \u4f6),以及反斜杠是否被二次转义写成了 \\u。Check that escapes are complete four-hex-digit sequences (\u4f60, not \u4f6) and that backslashes have not been double-escaped into \\u.
相关阅读Related Reading
中英文字数统计为什么对不上:字符、码点、Word 与编辑器的计数差异Why Chinese and English Word Counts Disagree: Characters, Code Points, Word vs Editor Counting
同一段文字,Word 说 320 字,编辑器说 412 字符,公众号后台又给了一个 356。这篇文章把"字数"背后的字符、码点、码元与分词规则讲清楚,让你再也不会被不同工具的数字搞晕The same paragraph: Word says 320 words, your editor says 412 characters, and the publishing backend reports 356. This article unpacks characters, code points, code units and tokenisation rules so you stop being confused by inconsistent counters.
HTML 实体编解码: 与空格的区别,以及 XSS 防护中的转义边界HTML Entity Encoding: Why Is Not a Space, and Escaping Boundaries in XSS Defense
` ` 看起来就是个空格,但 `trim()` 去不掉、`split(' ')` 切不开,因为它根本不是空格。本文从实体编码的原理讲起,结合 XSS 转义边界的真实案例,说清什么时候该转义、转义哪些字符。` ` looks like a space, but `trim()` won't remove it and `split(' ')` won't split on it — because it is not a space at all. This article starts from how entity encoding works, then uses real XSS escaping boundary cases to explain when to escape and which characters to escape.
相关工具Related Tools
Base64 编解码Base64 Encoder/Decoder
Base64编码与解码,支持文本和文件Base64 encode and decode, supports text and files.
URL 编解码URL Encoder/Decoder
URL编码与解码,处理特殊字符URL encode and decode, handle special characters.
HTML 实体编解码HTML Entity Encoder
HTML实体编码与解码HTML entity encoding and decoding.
进制转换Number Base Converter
二进制、八进制、十进制、十六进制互转Convert between binary, octal, decimal and hexadecimal.