인코딩
Unicode Escape
Unicode 이스케이프 시퀀스 인코딩 및 디코딩 — 문자를 \uXXXX 형식으로, 또는 그 반대로 변환.
A Unicode escape sequence (\uXXXX) writes a character as its code point instead of the character itself — so a string literal in code can contain any Unicode character while the source file itself stays plain ASCII.
How to use it
- Encode: paste text and every non-ASCII character gets replaced with its matching \uXXXX sequence.
- Decode: paste a string containing \uXXXX sequences to get plain, readable text back.
- Characters outside the Basic Multilingual Plane (most emoji) are encoded as a surrogate pair of two sequences.
Common uses
- Reading JSON or JS code where non-ASCII text was pre-escaped into \uXXXX for compatibility.
- Inserting a character that's not on the keyboard into code via an explicit Unicode escape.
- Debugging why a string with an emoji shows up as two odd characters — recognizing a surrogate pair.
Things to keep in mind
\uXXXX encodes exactly one 16-bit UTF-16 unit, not one visible character — characters outside the Basic Multilingual Plane (most emoji) need two such sequences together (a surrogate pair).
JSON only requires escaping for control characters and a few special characters — escaping every character as \uXXXX isn't required, though it is valid.
자주 묻는 질문
\uXXXX 형식은 무엇을 나타내나요?
\u 뒤에 4자리 16진수를 붙여 유니코드 문자 하나를 표현하는 이스케이프 표기법으로, JavaScript 문자열이나 JSON에서 특수 문자·비 ASCII 문자를 코드로 표현할 때 사용합니다.
이모지 같은 문자는 왜 \uXXXX 두 개로 나오나요?
기본 다국어 평면(BMP) 밖에 있는 이모지 등의 문자는 \uXXXX 하나로 표현할 수 없어서 서로게이트 페어라는 두 개의 코드 유닛(상위·하위 서로게이트)로 쪼개져 표현됩니다. 이는 JavaScript 문자열 내부 표현 방식과 동일합니다.
입력한 텍스트가 외부로 전송되나요?
아니요. 인코딩과 디코딩 모두 브라우저 안에서만 처리되며 서버로 전송되는 데이터는 없습니다.
서로게이트 쌍을 반으로 나누면 어떻게 되나요?
짝을 잃은, 유효하지 않은 "고아" 문자가 됩니다. 대부분의 파서는 이런 문자열을 오류로 거부하거나 대체 문자 "�"로 표시합니다.
이모지 문자를 \uXXXX 하나로 인코딩할 수 있나요?
아니요, 이모지가 기본 다국어 평면 밖에 있다면(대부분의 최신 이모지가 그렇습니다) 불가능합니다 — 이런 경우 항상 두 개의 \uXXXX 시퀀스로 이루어진 서로게이트 쌍이 필요합니다.