JSON style with a surrogate pair
Input
héllo 😀Output
h\u00e9llo 😀The emoji needs two escapes because JSON has no syntax for code points above U+FFFF.
Escaping converts characters into \u sequences so text survives a channel that cannot carry them, a source file that must stay ASCII, a legacy build tool, or a config format with an uncertain encoding.
The escape syntax differs by language, and the differences matter for characters outside the Basic Multilingual Plane. JSON has no syntax for them at all and needs surrogate pairs; JavaScript added \u{...}; Python uses \U with eight digits; CSS uses a bare backslash and hex digits.
Each example below is executed against this tool by the test suite, so what you see is what the tool actually produces.
Input
héllo 😀Output
h\u00e9llo 😀The emoji needs two escapes because JSON has no syntax for code points above U+FFFF.
Input
😀Output
\u{1f600}Modern JavaScript can express the code point directly.
The details that decide whether a conversion is correct, and where information can be lost without any error being raised.