Unicode Escape


Unicode Escape
Surrogate Pair

About Unicode escape sequence

Unicode escape sequences convert a single character to the format of a 4-digit hexadecimal code point, such as \uXXXX. For example, "A" becomes "\u0041".

Unicode non-BMP characters represented as surrogate pairs do not fit in the 4-digit code point, so they are represented in the following format for each programming language.

Programming languageFormatConversion result of "😀"(U+01F600)
Java, JS(ES5)\uXXXX\uXXXX\ud83d\ude00
Swift, JS(ES6+), PHP, Ruby\u{XXXXX}\u{1f600}
C, Python\U000XXXXX\U0001f600