HZ (character Encoding) - Structure and Use

Structure and Use

In the HZ encoding system, the character sequences "~{" and "~}" act as escape sequences; anything between them is interpreted as Chinese encoded in GB2312 (the most significant bits are ignored). Outside the escape sequences, characters are assumed to be ASCII.

An example will help illustrate the relationship between GB2312, EUC-CN, and the HZ code:

Various forms of the GB2312 code (0xD2BB) for the character "一" (one)
Form Code With escape sequences Remarks
Kuten / Qūwèi / 区位 form 5027 Zone (ku/qū/区) 50, point (ten/wèi/位) 27
ISO 2022 form 5216 3B16 0E16 5216 3B16 0F16 50 + 32 = 82 = 5216
EUC-CN form D216 BB16 D216 BB16 5216 ∨ 8016 = D216
HZ form (standard) 5216 3B16 7E16 7B16 5216 3B16 7E16 7D16 Appears as ~{R;~} without HZ decoder
HZ form (alternate) D216 BB16 7E16 7B16 D216 BB16 7E16 7D16 EUC form acceptable to at least some decoders

HZ was originally designed to be used purely as a 7-bit code. However, when situations allow, the escape sequences "~{" and "~}" sometimes surround characters represented in EUC-CN; this alternative use allows Chinese to be readable either with the help of HZ decoder software, or with a system that understands EUC-CN.

Additionally, the specification defines that

  • the sequence "~~" is to be treated as encoding a single ASCII "~"
  • the character "~" followed by a newline is to be discarded.

However, not all HZ decoders follow these two rules.

Read more about this topic:  HZ (character Encoding)

Famous quotes containing the word structure:

    I’m a Sunday School teacher, and I’ve always known that the structure of law is founded on the Christian ethic that you shall love the Lord your God and your neighbor as yourself—a very high and perfect standard. We all know the fallibility of man, and the contentions in society, as described by Reinhold Niebuhr and many others, don’t permit us to achieve perfection.
    Jimmy Carter (James Earl Carter, Jr.)