How it works
☕ → U+2615 → \u2615Every character has a number in Unicode, its code point, written U+ and hex: “☕” is U+2615. Programming languages let you write a character by that number, which keeps source files plain ASCII. Characters above U+FFFF, like most emoji, need two \u escapes in JavaScript and JSON (a surrogate pair), or one \u{…} or \U escape where the language allows it.
-
Find the code point
é = U+00E9 · ☕ = U+2615 · 😀 = U+1F600 -
Up to U+FFFF: four hex digits
☕ → \u2615 -
Above U+FFFF: a surrogate pair
1F600 − 10000 = F600 → D800 + (F600 ÷ 400) = D83D, DC00 + (F600 mod 400) = DE00 → \uD83D\uDE00
Escape styles
| Style | ☕ | 😀 | Used in |
|---|---|---|---|
| \uXXXX | \u2615 | \uD83D\uDE00 | JavaScript, JSON, Java, C# |
| \u{…} | \u{2615} | \u{1F600} | modern JavaScript, Rust, Swift |
| \UXXXXXXXX | \u2615 | \U0001F600 | Python, C, C++ |
| U+XXXX | U+2615 | U+1F600 | Unicode charts |
| &#x…; | ☕ | 😀 | HTML, XML |
Python and C write characters up to U+FFFF with \u too; \U is for the ones above.
Good to know
- Unescape understands all of these: \u2615, \uD83D\uDE00, \u{1F600}, \U0001F600, \xE9, U+2615 and ☕.