Standard Compression Scheme for Unicode: Difference between revisions

Content deleted Content added
m Fix incorrect capitalization
 
(8 intermediate revisions by 5 users not shown)
Line 1:
{{Short description|Unicode Technical Standard}}
{{expand German|date=August 2013}}
The '''Standard Compression Scheme for Unicode''' (SCSU)<ref>{{cite web |url=https://www.unicode.org/reports/tr6/ |title=UTS #6: Compression Scheme for Unicode |date=2005-05-06 |quote=SCSU defines a compact encoding, which is sometimes useful. However, Unicode text is much more commonly stored and transmitted in [[UTF-8]] which is less compact (except for [[ASCII]]), much simpler, and does not present any security issues. For longer texts, general-purpose compression is effective and common.|access-date=2008-06-13}}</ref> is a [[Unicode]] Technical Standard for reducing the number of [[byte]]s needed to represent Unicode text, especially if that text uses mostly characters from one or a small number of per-language character blocks. It does so by dynamically mapping values in the range 128&ndash;255 to offsets within particular blocks of 128 characters. The initial conditions of the encoder mean that existing strings in [[ASCII]] and [[ISO-8859-1]] that do not contain C0 control codes other than NULL TAB CR and LF can be treated as SCSU strings. Since most alphabets do reside in blocks of contiguous Unicode codepoints, texts that use small alphabets and either ASCII punctuation or punctuation that fits within the window for the main alphabet can be encoded at one byte per character (plus setup overhead, which for common languages is often only 1 byte), most other punctuation can be encoded at 2 bytes per symbol through non-locking shifts. SCSU can also switch to [[UTF-16]] internally to handle non-alphabetic languages.
 
==History & use ==
[[Reuters]] originally developed SCSU, then under the name RSCURCSU for Reuters Compression Scheme for Unicode.<ref>{{Cite web|url=https://unicode.org/iuc/iuc9/Friday2.html#b3|title = Ninth International Unicode Conference - Friday - Track B}}</ref><ref>{{Cite web|url=https://unicode.org/iuc/iuc10/program.html|title=Tenth International Unicode Conference - Conference Program}}</ref><ref>{{Cite web|url=https://unicode.org/reports/tr6-10.html|title=Compression Scheme for Unicode}}</ref><ref name=Ewellic>{{Cite web|url=https://webwww.archiveunicode.org/webnotes/20190508064108tn14/ewellicUnicodeCompression.org/compression.html#scsupdf|title = A survey of Unicode compression}}</ref>
 
At first the Unicode Consortium considered it to be a character encoding,<ref>{{Cite web|url=https://unicode.org/reports/tr17/tr17-2.html|title = UTR#17: Character Encoding Model}}</ref> but in 1999 changed its mind: although it was still considered a transfer encoding syntax, for a while it was no longer considered a character encoding because different compressors might yield different outputs for the same text.<ref>https://unicode.org/reports/tr17/tr17-3.html#Transfer Encoding Syntax</ref> However, in 2004 this decision was reverted and now SCSU is considered a ''compressing'' character encoding scheme, as opposed to a simple or compound character encoding scheme.<ref>{{Cite web|url=https://unicode.org/L2/L2004/04288-tr17-5d2.html#CharacterEncodingScheme|title=UTR#17: Character Encoding Model|date=2004-07-14}}</ref><ref>{{Cite web |title=UTR#17: Unicode Character Encoding Model |url=https://unicode.org/reports/tr17/ |access-date=2023-11-14 |website=unicode.org}}</ref>
 
Roman Czyborra (of [[GNU Unifont]]) wrote a decompressor.<ref>{{Cite web| title=This is a deflator to UTF-8 output for input compressed in SCSU | url=https://czyborra.com/scsu/scsu.c {{Bare| URLarchive-url=https://web.archive.org/web/19990908230458/http://czyborra.com:80/scsu/scsu.c plain text| archive-date=March 20221999-09-08}}</ref> The IBM-contributed decompressor is found in [[International Components for Unicode]], along with a compressor written in Java.<ref>{{Cite web|url=https://github.com/unicode-org/icu/blob/3f043c7693e20c8cded76035918dad104e7256e3/icu4j/main/classes/charset/src/com/ibm/icu/charset/CharsetSCSU.java|title = International Components for Unicode|website = [[GitHub]]|date = 22 October 2021}}</ref> Simpler reference codecs are available as attachments to TR6.
 
[[Symbian OS]], an operating system for mobile phones and other mobile devices, uses SCSU to serialize strings.
Line 20 ⟶ 21:
 
=== Window encoding ===
The core of SCSU lies in the windows for which the meanings of bytes 0x80-0xff are defined. There are eight static windows for simpler scripts and punctuation, and 6 types of dynamic windows (plus "half Unicode block" windows and custom Windowswindows for the supplementary planes) for scripts making use of more characters.
 
Both simple and dynamic windows are selected by special command characters. For individual characters that do not fit into the current block, command characters for quoting are provided.
 
== Comparison with general-purpose plain text compression schemes ==
Because UTF-16 or UTF-8 text might occupy more space than its equivalent in pre-Unicode encodings did, one might want to use compression such as SCSU to mitigate this problem.<ref>{{Cite web| title=Implementation Guidelines | url=https://unicode.org/versions/Unicode3.0.0/ch05.pdf {{Bare| URLarchive-url=https://web.archive.org/web/20150730234318/http://www.unicode.org/versions/Unicode3.0.0/ch05.pdf PDF| archive-date=March 20222015-07-30}}</ref> In comparison with general-purpose compressors, it is not necessarily advantageous to use SCSU.<ref name=Ewellic/> Also, while it can be used as a text encoding, because of the stateful nature of the algorithm difficulties may arise when using it as an internal text representation since basic text operations become non-trivial.
 
Treated purely as a compression algorithm, SCSU is inferior to most commonly used general-purpose algorithms for texts of over a few kilobytes.