Big5
การเข้ารหัสอักษรจีนตัวเต็มที่ใช้ส่วนใหญ่ในไต้หวันและฮ่องกง เข้ารหัสอักขระ CJK ประมาณ 13,000 ตัว
What is Big5?
Big5 is a Traditional Chinese character encoding standard developed in Taiwan in 1984 by a consortium of five companies (hence "Big Five"). It uses a double-byte scheme where each Chinese character is represented by 2 bytes, while ASCII characters remain as single bytes. Big5 is the dominant encoding for Traditional Chinese text used in Taiwan, Hong Kong, and Macau.
Understanding Big5 matters for anyone working with legacy Chinese text data, web scraping Chinese websites, processing historical documents from Taiwan or Hong Kong, or maintaining systems that predate the widespread adoption of Unicode.
How Big5 Works
Big5 is a double-byte character encoding (DBCS):
- ASCII characters (0x00–0x7F): Encoded as single bytes, identical to ASCII.
- Chinese characters: Encoded as 2-byte sequences where the first byte (high byte) is in the range 0x81–0xFE and the second byte (low byte) is in the range 0x40–0x7E or 0xA1–0xFE.
The original Big5 standard covered 13,053 characters: - Level 1: 5,401 frequently used characters (common vocabulary) - Level 2: 7,652 less-common characters
Note the unusual gap in the low-byte range: 0x7F and 0x80 are excluded from the low-byte range to avoid conflicts with ASCII DEL (0x7F) and to allow certain software to use 0x80 as a sentinel value.
Extensions and Variants
Because the original Big5 had gaps and limitations, numerous extensions were created:
| Variant | Notes |
|---|---|
| Big5-HKSCS | Hong Kong Supplementary Character Set — adds 4,702+ characters for Cantonese and Hong Kong usage |
| Big5+ | Extended by the Chinese National Standard Institute with ~7,000 more characters |
| Big5-2003 | Taiwan's current standard (CNS 11643 integrated) |
| CP950 | Microsoft's Big5 variant used in Windows Traditional Chinese |
The HKSCS extension is particularly important for Cantonese text because Cantonese has many characters specific to the spoken dialect that do not appear in Mandarin-oriented Big5.
Code Examples
# Python: Big5 encoding/decoding
text = '你好世界' # "Hello World" in Chinese
# Encode to Big5
encoded = text.encode('big5')
print(encoded) # b'\xa7A\xa6n\xa5@\xac\xc9'
print(len(encoded)) # 8 bytes for 4 Chinese characters
# Decode from Big5
decoded = b'\xa7A\xa6n'.decode('big5')
print(decoded) # '你好'
# Python supports multiple Big5 variants
'你'.encode('big5') # Standard Big5
'你'.encode('big5hkscs') # Hong Kong Supplementary Character Set
'你'.encode('cp950') # Microsoft variant
# Check for characters not in Big5
try:
'𠀀'.encode('big5') # Rare CJK extension B character
except UnicodeEncodeError as e:
print(f"Cannot encode: {e}")
Encoding Conflicts with ASCII
The most significant technical hazard of Big5 is that the second byte of a two-byte sequence can overlap with printable ASCII values (0x40–0x7E includes @, A–Z, a–z, etc.). This means a naive scanner cannot reliably find ASCII characters within a Big5 stream by scanning byte-by-byte — it must track whether it is inside a two-byte sequence.
The byte 0x5C is the backslash in ASCII. In Big5, it can appear as the second byte of a two-byte sequence. Early versions of software designed for ASCII would misinterpret this second byte as a backslash, causing path-separator bugs, SQL injection vulnerabilities, and other security issues.
Quick Facts
| Property | Value |
|---|---|
| Full Name | Big Five (五大碼) |
| Developed | 1984, Taiwan |
| Bytes per character | 1 (ASCII) or 2 (Chinese) |
| Original coverage | ~13,053 Traditional Chinese characters |
| Region | Taiwan, Hong Kong, Macau |
| Common variant | Big5-HKSCS (Hong Kong) |
| IANA charset name | Big5 |
| Windows code page | CP950 |
Common Pitfalls
Confusing Big5 with GB2312/GBK. Big5 encodes Traditional Chinese characters used in Taiwan; GB2312/GBK encodes Simplified Chinese used in mainland China. These are entirely different encodings with non-overlapping byte ranges for Chinese characters. A Big5 file decoded as GBK produces complete garbage.
The backslash vulnerability. As noted above, Big5 second bytes can be 0x5C (backslash). In security-sensitive applications, never scan Big5 text byte-by-byte looking for ASCII delimiters without full two-byte sequence awareness. This class of vulnerability has been exploited in SQL injection attacks against older web applications.
Incomplete Big5 support in libraries. Not all libraries support Big5-HKSCS or Big5+. Characters unique to Hong Kong Cantonese may fail to encode in software that only implements the original Big5 standard.
คำศัพท์ที่เกี่ยวข้อง
เพิ่มเติมใน การเข้ารหัส
มาตรฐานรหัสข้อมูลของอเมริกา (American Standard Code for Information Interchange) การเข้ารหัส 7 บิตครอบคลุม 128 ตัวอักษร …
Visual art created from text characters, originally limited to the 95 printable …
Binary-to-text encoding that represents binary data using 64 ASCII characters (A–Z, a–z, …
Extended Binary Coded Decimal Interchange Code รหัสเข้ารหัสของเมนเฟรม IBM ที่มีช่วงตัวอักษรไม่ต่อเนื่อง ยังคงใช้ในธนาคารและเมนเฟรมองค์กร
การเข้ารหัสอักขระภาษาเกาหลีที่อิงตาม KS X 1001 แมปอักษรฮันกึลและฮันจาเป็นลำดับสองไบต์
กลุ่มการเข้ารหัสอักษรจีนตัวย่อ: GB2312 (6,763 อักขระ) พัฒนาเป็น GBK แล้วเป็น GB18030 ซึ่งเป็นมาตรฐานแห่งชาติจีนที่บังคับใช้และเข้ากันได้กับ Unicode
กลุ่มการเข้ารหัสไบต์เดี่ยว 8 บิตสำหรับกลุ่มภาษาต่างๆ ISO 8859-1 (Latin-1) เป็นพื้นฐานของ 256 จุดรหัสแรกของ Unicode
การเข้ารหัสอักขระภาษาญี่ปุ่นที่ผสม ASCII/JIS Roman แบบไบต์เดี่ยวกับคันจิ JIS X 0208 แบบสองไบต์ ยังคงใช้งานในระบบญี่ปุ่นรุ่นเก่า
การเข้ารหัส 2 ไบต์แบบความยาวคงที่ที่ล้าสมัย ครอบคลุมเฉพาะ BMP (U+0000–U+FFFF) เป็นรุ่นก่อนของ UTF-16 ที่ไม่สามารถแสดงอักขระเสริมได้
การเข้ารหัส Unicode แบบความยาวแปรผันที่ใช้ 2 หรือ 4 ไบต์ (1 หรือ 2 หน่วยรหัส 16 …