Surrogate Pair

Encoding & Standards

หน่วยโค้ด UTF-16 สองตัว (surrogate สูง U+D800-U+DBFF ตามด้วย surrogate ต่ำ U+DC00-U+DFFF) ที่แสดงอักขระที่อยู่เหนือ U+FFFF ร่วมกัน

Characters with code points above U+FFFF cannot fit in a single 16-bit value. UTF-16 solves this by encoding them as two 16-bit values called a surrogate pair. Since most emoji are above U+FFFF, surrogate pairs are extremely common with emoji.

For example, 😀 (U+1F600) becomes the surrogate pair 0xD83D 0xDE00 in UTF-16. The formula: high surrogate = 0xD800 + ((cp - 0x10000) >> 10), low surrogate = 0xDC00 + ((cp - 0x10000) & 0x3FF).

This is why JavaScript's `'😀'.charCodeAt(0)` returns 55357 (0xD83D) — it's returning the high surrogate, not the actual code point.

คำที่เกี่ยวข้อง

Supplementary Multilingual Plane (SMP) Supplementary Multilingual Plane (SMP)
Unicode เพลน 1 (U+10000 ถึง U+1FFFF) ซึ่งเป็นที่จัดสรรโค้ดพอยท์ของอิโมจิส่วนใหญ่
UTF-16 UTF-16
การเข้ารหัส Unicode แบบความกว้างผันแปร ใช้ 2 หรือ 4 ไบต์ต่ออักขระ ใช้ภายในโดย JavaScript, Java และ Windows
โค้ดยูนิต โค้ดยูนิต
การรวมบิตขั้นต่ำที่ใช้เข้ารหัสอักขระ: 8 บิตสำหรับ UTF-8, 16 บิตสำหรับ UTF-16 และ 32 บิตสำหรับ UTF-32
เพลน เพลน
กลุ่มโค้ดพอยท์ Unicode ที่ต่อเนื่องกัน 65,536 ตัว เพลน 0 คือ Basic Multilingual Plane (BMP) และอิโมจิส่วนใหญ่อยู่ในเพลน 1 (SMP)

เครื่องมือที่เกี่ยวข้อง

🔢 ค้นหา Unicode ค้นหา Unicode
ป้อนจุดรหัสเช่น U+1F600 และรับ emoji, รายละเอียดการเข้ารหัส, ไบต์ UTF-8/16 และ HTML entities
🔍 ตัววิเคราะห์ลำดับ ตัววิเคราะห์ลำดับ
ถอดรหัสลำดับ ZWJ, ตัวปรับแต่งสีผิว, ลำดับ keycap และคู่ธงเป็นส่วนประกอบแต่ละชิ้น