Contents
Binary Ordered Compression for Unicode
Binary Ordered Compression for Unicode (BOCU) is a MIME compatible Unicode compression scheme. BOCU-1 combines the wide applicability of UTF-8 with the compactness of Standard Compression Scheme for Unicode (SCSU). This Unicode encoding is designed to be useful for compressing short strings, and maintains code point order. BOCU-1 is specified in a Unicode Technical Note. For comparison SCSU was adopted as standard Unicode compression scheme with a byte/code point ratio similar to language-specific code pages. SCSU has not been widely adopted, as it is not suitable for MIME "text" media types. For example, SCSU cannot be used directly in emails and similar protocols. SCSU requires a complicated encoder design for good performance. Usually, the zip, bzip2, and other industry standard algorithms compact larger amounts of Unicode text more efficiently. Both SCSU and BOCU-1 are IANA registered charsets.
Details
All numbers in this section are hexadecimal, and all ranges are inclusive. Code points from to are encoded in BOCU-1 as the corresponding byte value. All other code points (that is, through and through ) are encoded as a difference between the code point and a normalized version of the most recently encoded code point that was not an ASCII space. The initial state is. The normalization mapping is as follows: The difference between the current code point and the normalized previous code point is encoded as follows: Each byte range is lexicographically ordered with the following thirteen byte values excluded:. For example, the byte sequence, coding for a difference of , is immediately followed by the byte sequence , coding for a difference of. Any ASCII input to excluding space resets the encoder to. Because the above-mentioned values cover line end code points and as is, the encoder is in a known state at the begin of each line. The corruption of a single byte therefore affects at most one line. For comparison, the corruption of a single byte in UTF-8 affects at most one code point, for SCSU it can affect the entire document. BOCU-1 offers a similar robustness also for input texts without the above-mentioned values with the special reset code. When a decoder finds this octet it resets its state to as for a line end. The use of reset bytes is not recommended in the BOCU-1 specification, because it conflicts with other BOCU-1 design goals, notably the binary order. The optional use of a signature at the begin of BOCU-1 encoded texts, i.e. the BOCU-1 byte sequence , changes the initial state to. In other words, the signature cannot simply be stripped as in most other Unicode encoding schemes. Adding a reset byte after the signature could avoid this effect, but the BOCU-1 specification does not recommend this practice. In theory UTF-1 and UTF-8 could encode the original UCS-4 set with 31 bits up to. BOCU-1 and UTF-16 can encode the modern Unicode set from to. Excluding the thirteen protected code points encoded as single octets BOCU-1 can use octets in multi-byte encodings. BOCU-1 needs at most four bytes consisting of a lead byte and one to three trail bytes. The trail bytes encode a remaining "modulo 243" (base 243) difference, the lead byte determines the number of trail bytes and an initial difference. Note that the reset byte is not protected and can occur as trail byte.
Patent
Prior to 16 November 2022, the general BOCU algorithm was covered by United States Patent #6,737,994, which also mentions the specific BOCU-1 implementation. This patent has now expired. IBM, which employed both of the inventors of BOCU-1 at the time it was created, stated in the Unicode Technical Note that implementers of a "fully compliant version of BOCU-1" had to contact IBM to request a royalty-free license. BOCU-1 is the only Unicode compression scheme described on the Unicode Web site that is known to have been encumbered with intellectual property restrictions. By contrast, IBM also filed for a patent on UTF-EBCDIC, but it chose in that case to make the documentation and encoding scheme "freely available to anyone concerned towards making the transformation format as part of the UCS standards", instead of requiring implementers to request a license.
This article is derived from Wikipedia and licensed under CC BY-SA 4.0. View the original article.
Wikipedia® is a registered trademark of the
Wikimedia Foundation, Inc.
Bliptext is not
affiliated with or endorsed by Wikipedia or the
Wikimedia Foundation.