> \u0048 | javascript | unicode <
// JavaScript Unicode Escape - Convert text to \uXXXX or \u{} format
JS Compatible
Standard JavaScript/JSON unicode escape sequences.
Modern Syntax
Support for ES6 \u{} format for astral plane characters.
Full Unicode
Handle emojis and characters outside the BMP.
>> technical info
How JavaScript Unicode Escapes Work:
JavaScript uses \uXXXX for Basic Multilingual Plane characters (U+0000 to U+FFFF). ES6 introduced \u{} syntax for any Unicode code point, including emojis and astral plane characters.
Examples:
'A' → \u0041 '😀' → \u{1F600} (ES6) ' ' → \n
Why Use Unicode Escapes:
- >JSON string encoding
- >JavaScript source code
- >Configuration files
- >Cross-platform compatibility
- >Debugging special characters
>> frequently asked questions
What are JavaScript Unicode escapes?
JavaScript Unicode escapes are sequences like \uXXXX that represent Unicode characters in source code. They allow you to include any Unicode character in JavaScript strings, even if your editor doesn't support them.
What's the difference between \uXXXX and \u{}?
\uXXXX is limited to 4 hex digits (BMP characters only). \u{} was introduced in ES6 and can use 1-6 hex digits, supporting all Unicode characters including emojis and astral plane characters.
When should I use Unicode escapes?
Use Unicode escapes when: writing JSON that needs special characters, ensuring cross-platform compatibility, embedding non-ASCII characters in JavaScript source, or when your development environment doesn't support certain characters.
How do I handle emojis?
Emojis are in the astral plane (above U+FFFF). Use ES6 \u{} syntax (e.g., \u{1F600} for 😀) or encode as surrogate pairs with two \uXXXX sequences in older JavaScript.