Unicode Escapes: One Character, Two Notations

Open Tool Unicode Escape Converter

Characters, code points, escape strings

Every character has a Unicode code point written as U plus hex, such as U+4E2D for a Han character. Programs often use escape strings instead, and the four-hex-digit form denotes a sixteen-bit code unit covering only the basic plane. Characters beyond that plane, most emoji among them, need two code units forming a surrogate pair. The tool works three ways: text to four-digit escapes, escapes back to text, and text to full code points. Knowing which output you hold decides whether it can go straight into code.

Steps

  1. Paste text, whole paragraphs or single characters.
  2. Choose text to escapes, escapes to text, or text to code points.
  3. Run it and verify prefix and digit count.
  4. Emoji produce two escapes, which is a surrogate pair rather than duplication.
  5. Copy the result and test it in a small page first.
  6. Reset for the next case.

Basic plane, surrogate pairs, size

The basic plane ends where four hex digits are exhausted, and anything above needs a pair with high and low units in reserved ranges. Writing a five-digit code point and jamming it into a four-digit escape is a common slip that parsers read as garbage. Conversely, copying only half a surrogate pair loses the character on decoding. Escaping inflates size, six characters per Han glyph, so whole-document conversion multiplies file size and belongs only in fields that need it. Code points aid searching and comparison, escapes embed into environments that cannot carry the literal character.

Common mistakes

Taking one escape from an emoji yields half a character. Pasting a code point where an escape is expected breaks syntax. Truncating five digits to four corrupts the glyph. Escaping an entire article destroys readability and bloats size. Mixed case in escapes trips some parsers. And shipping untested output leaves characters invisible in production.

Where escaping should not go

It is not a way around content review or filtering, and that use is wrong. Chinese prose is written literally by default, with escapes reserved for technical settings. Mojibake belongs to the encoding repair tool, not to escaping. Regex escaping is a different operation and must not be confused with character escaping. And escaping an entire configuration file makes every later edit harder.

⏫︎