UNICODE(7) Linux Programmer’s Manual UNICODE(7)
名前
Unicode - 汎用文字集合
説明
国際規格 ISO 10646 は 汎用文字集合 (Universal Character Set (UCS)) を定
義している。 UCS は他規格の文字集合の文字を全て含んでいる。さらに、 双
方 向の互換性 (round-trip compatibility) を保証する。例えば他の符号から
UCS に変換しさらに元の符号に変換したとしても、何の情報も失なわれない よ
うに変換テーブルを作成することができる。
UCS は現実的に知られている全ての言語を表現するのに必要な文字を含んでい
る。これにはラテン文字、ギリシャ文字、キリル文字、ヘブライ文字、アラ ビ
ア 文字、アルメニア文字、グルジア文字だけでなく、中国・日本・韓国で使わ
れている漢字、さらには、平仮名、片仮名、ハングル文字、デーヴァナーガ リ
ー 文字、ベンガル文字、グルムキー文字、グジャラート文字、オリヤー文字、
タミール文字、テルグ文字、カナラ文字、マラヤーラム文字、タイ文字、ラ オ
ス文字、クメール文字、ボポモフォ文字 (注音字母)、チベット文字、ルーン文
字、エチオピア文字、カナダ音節文字、チェロキー文字、モンゴル文字、オ ガ
ム 文字、ミャンマー文字、シンハラ文字、ターナ文字、イ (彝) 文字などが含
まれる。まだカバーされていない文字に付いても、コンピュータで使用する た
め にどのようなエンコードがもっとも良いかという研究が進められており、最
終的には追加されるだろう。ヒエログリフや歴史的ないろいろなインド=ヨ ー
ロ ッパ言語だけでなく、テングワール文字、キアス文字、クリンゴン文字など
の人工的な言語も選ばれている。 UCS は、これらの文 字 に 加 え て 、TeX,
PostScript, APL, MS-DOS, MS-Windows, Macintosh, OCR フォント、数多くの
ワードプロセッサーや出版システム、などが提供する図形記号・印字記号・ 数
学記号・科学記号などの多くを含むようになった。
UCS 規格 (ISO 10646) は 31ビットの文字集合アーキテクチャーを記述してお
り、128 個の 24 ビット 群 (group) から構成されている。各群は 256 個 の
16 ビ ット 面 (plane) に分割されており、各文字は 256 個の 8 ビット 区
(row) の 256 点 (column) の中に位置する。 こ の 規 格 の Part 1 (ISO
10646-1) では、最初の 65534 個のコード位置 (0x0000 〜 0xfffd) を定義し
ている。これは第 0 群の第 0 面である 基本多言語面 (Basic Multilingual
Plane (BMP)) を構成する。この規格の Part 2 (ISO 10646-2) では、第 0 群
の BMP の外部である 0x10000 〜 0x10ffff の範囲にある 補助面に文字を追加
し た。この規格では 0x10ffff を越えた位置に文字を追加する予定はないので
、予想できる将来においては、全コード空間のうちグループ 0 の一部分は実際
には使われることはない。 BMP には他の文字集合で一般に使われる全ての文字
が含まれている。 ISO 10646-2 で追加された補助面は、特定の科学分野・辞書
出 版・印刷産業・高次プロトコル・何かのファンの間などで使われる特殊な文
字だけをカバーする。
UCS 文字を 2 バイトのワードで表現するのが UCS-2 形式である (BMP 文字 の
み) 。また、 UCS-4 では文字を 4 バイトのワードで表現する。さらに、ASCII
を処理するソフトウェアへの下位互換のために UTF-8 エンコード形式がある。
また、0x10ffff までの非 BMP 文字を扱う UCS-2 対応ソフトウェアとの互換の
ために UTF-16 エンコード形式がある。
UCS 文字集合の 0x0000 から 0x007f は、古典的な US-ASCII 文字集合の文 字
と 同 じである。また 0x0000 から 0x00ff の範囲では、 ISO 8859-1 Latin-1
文字集合の文字と同じである。
合成文字 (Combining Characters)
UCS のいくつかのコード・ポイントは 合成文字 (combining characters) に割
り 当てられている。これらはタイプライターの移動しないアクセント・キーに
似ている。合成文字は直前の文字にアクセントのみを加える。最も重要なア ク
セント付きの文字はそれ自身のコードを UCS に持っている。一方で合成文字機
構は全ての文字にアクセントや発音区別符号を加えることができる。合成文 字
は 常 に そ れ が 修正する文字に続く。例えばドイツ語の文字 A ウムラウト
("Latin capital letter A with diaeresis") は UCS に前もって準備されたコ
ー ド 0x00c4 で も 、通常の A "Latin capital letter A" に "combining
diaeresis (合成分音記号)" を続けた組合せ (0x0041 0x0308) のどちらでも表
現することができる。
合 成文字は、タイ文字や数学植字のエンコード・国際音声字母を使うユーザー
などには必須である。
実装レベル
全てのシステムに合成文字のような進んだサポートを期待しているわけでは な
い。 ISO 10646-1 は以下の三段階の UCS の実装レベルを指定している。
Level 1 合成文字と ハングル・ジャモ文字 (いろいろな韓国・朝鮮文字の符
号化。この符号化では、ハングル音節のグリフが 3 つまたは 2 つの
母音・子音コードの組み合わせで符号化される) はサポートしない。
Level 2 Level 1 と同様だが、合成文字を必須とする言語のための文字 (例え
ば、タイ文字・ラオス文字・ヘブライ文字・アラビア文字・デーヴァ
ナーガリー文字・マレヤーラム文字など) は使える。
Level 3 全ての UCS 文字をサポートする。
ユニコード・コンソーシアム (Unicode Consortium) から発行された Unicode
3.0 Standard は、ISO 10646-1:2000 に記述された UCS Basic Multilingual
Plane の level 3 実装と全く同じである。 Unicode 3.1 では ISO 10646-2 の
補助面が追加されている。 Unicode Consortium から発行される Unicode 規格
と技術レポートにより、いろいろな文字の意味と推奨される使用法について の
更 なる情報が得られる。これらの規格書や技術レポートで、Unicode 文字列を
編集・並べ替え・比較・正規化・変換・表示するためのガイドラインとアル ゴ
リズムが分かる。
Linux における Unicode
GNU/Linux では、C 言語の型 wchar_t は符号付き 32 ビット整数型である。そ
の値は C ライブラリにより (すべてのロケールにおいて) 常に UCS コード の
値として解釈される。これを GNU C ライブラリがアプリケーションに知らせる
ための規約として、定数 __STDC_ISO_10646__ を定義する。これは ISO C99 規
格で指定されている。
ASCII 互換の UTF-8 マルチバイトエンコードでは、入出力ストリーム・端末通
信・プレーンテキストファイル・ファイル名・環境変数において 、 UCS/Uni-
code を ASCII のように使うことができる。 UTF-8 を文字エンコードとして使
うことを全てのアプリケーションに知らせるためには、 ("LANG=en_GB.UTF-8"
のように) 環境変数を使って適切な ロケール (locale) を選択しなければなら
ない。
nl_langinfo(CODESET) 関数は選択されたエンコードの名前を返す。内部 的 な
wchar_t 文字や文字列をシステム文字列エンコードに変換 (逆変換) するのに
使われる wctomb(3) や mbsrtowcs(3)、さらには wcwidth(3) といったライ ブ
ラリ関数は、文字出力でどれだけカーソルが進んだか (0–2) を返す。
一 般的に言うと、Linux では現在のところ BMP の level 1 実装のみを使うべ
きである。ある言語の文字 (とくにタイ文字) では、ベース文字当たり 2 つま
で の 合 成文字を使うことが UTF-8 端末エミュレータと ISO 10646 フォント
(level 2) でサポートされている。しかし一般的に言えば、もし可能ならば あ
ら か じめ合成した文字を使うべきである (Unicode では、これを Normaliza-
tion Form C (合成文字の正規化形式) という)。
プライベート・エリア
BMP の 0xe000 〜 0xf8ff の範囲は、規格ではいかなる文字も割り当てず、 私
的な使用のために予約されている。 Linux コミュニティでは、このプライベー
ト・エリアをさらに細かく分割して使用する。 0xe000 〜 0xefff の範囲は エ
ン ド・ユーザーが個々に使用することができる。 0xf000 〜 0xf8ff の範囲は
Linux Zone で全ての Linux ユーザーで共通に使用する。 Linux Zone への 文
字 割り当ての登録は、現在 H. Peter Anvin
UNICODE(7) Linux Programmer’s Manual UNICODE(7)
NAME
Unicode - the Universal Character Set
DESCRIPTION
The international standard ISO 10646 defines the Universal Character
Set (UCS). UCS contains all characters of all other character set
standards. It also guarantees round-trip compatibility, i.e., conver-
sion tables can be built such that no information is lost when a string
is converted from any other encoding to UCS and back.
UCS contains the characters required to represent practically all known
languages. This includes not only the Latin, Greek, Cyrillic, Hebrew,
Arabic, Armenian, and Georgian scripts, but also Chinese, Japanese and
Korean Han ideographs as well as scripts such as Hiragana, Katakana,
Hangul, Devanagari, Bengali, Gurmukhi, Gujarati, Oriya, Tamil, Telugu,
Kannada, Malayalam, Thai, Lao, Khmer, Bopomofo, Tibetan, Runic,
Ethiopic, Canadian Syllabics, Cherokee, Mongolian, Ogham, Myanmar, Sin-
hala, Thaana, Yi, and others. For scripts not yet covered, research on
how to best encode them for computer usage is still going on and they
will be added eventually. This might eventually include not only
Hieroglyphs and various historic Indo-European languages, but even some
selected artistic scripts such as Tengwar, Cirth, and Klingon. UCS
also covers a large number of graphical, typographical, mathematical
and scientific symbols, including those provided by TeX, Postscript,
APL, MS-DOS, MS-Windows, Macintosh, OCR fonts, as well as many word
processing and publishing systems, and more are being added.
The UCS standard (ISO 10646) describes a 31-bit character set architec-
ture consisting of 128 24-bit groups, each divided into 256 16-bit
planes made up of 256 8-bit rows with 256 column positions, one for
each character. Part 1 of the standard (ISO 10646-1) defines the first
65534 code positions (0x0000 to 0xfffd), which form the Basic Multilin-
gual Plane (BMP), that is plane 0 in group 0. Part 2 of the standard
(ISO 10646-2) adds characters to group 0 outside the BMP in several
supplementary planes in the range 0x10000 to 0x10ffff. There are no
plans to add characters beyond 0x10ffff to the standard, therefore of
the entire code space, only a small fraction of group 0 will ever be
actually used in the foreseeable future. The BMP contains all charac-
ters found in the commonly used other character sets. The supplemental
planes added by ISO 10646-2 cover only more exotic characters for spe-
cial scientific, dictionary printing, publishing industry, higher-level
protocol and enthusiast needs.
The representation of each UCS character as a 2-byte word is referred
to as the UCS-2 form (only for BMP characters), whereas UCS-4 is the
representation of each character by a 4-byte word. In addition, there
exist two encoding forms UTF-8 for backwards compatibility with ASCII
processing software and UTF-16 for the backwards compatible handling of
non-BMP characters up to 0x10ffff by UCS-2 software.
The UCS characters 0x0000 to 0x007f are identical to those of the clas-
sic US-ASCII character set and the characters in the range 0x0000 to
0x00ff are identical to those in ISO 8859-1 Latin-1.
Combining Characters
Some code points in UCS have been assigned to combining characters.
These are similar to the non-spacing accent keys on a typewriter. A
combining character just adds an accent to the previous character. The
most important accented characters have codes of their own in UCS, how-
ever, the combining character mechanism allows us to add accents and
other diacritical marks to any character. The combining characters
always follow the character which they modify. For example, the German
character Umlaut-A ("Latin capital letter A with diaeresis") can either
be represented by the precomposed UCS code 0x00c4, or alternatively as
the combination of a normal "Latin capital letter A" followed by a
"combining diaeresis": 0x0041 0x0308.
Combining characters are essential for instance for encoding the Thai
script or for mathematical typesetting and users of the International
Phonetic Alphabet.
Implementation Levels
As not all systems are expected to support advanced mechanisms like
combining characters, ISO 10646-1 specifies the following three imple-
mentation levels of UCS:
Level 1 Combining characters and Hangul Jamo (a variant encoding of
the Korean script, where a Hangul syllable glyph is coded as a
triplet or pair of vovel/consonant codes) are not supported.
Level 2 In addition to level 1, combining characters are now allowed
for some languages where they are essential (e.g., Thai, Lao,
Hebrew, Arabic, Devanagari, Malayalam, etc.).
Level 3 All UCS characters are supported.
The Unicode 3.0 Standard published by the Unicode Consortium contains
exactly the UCS Basic Multilingual Plane at implementation level 3, as
described in ISO 10646-1:2000. Unicode 3.1 added the supplemental
planes of ISO 10646-2. The Unicode standard and technical reports pub-
lished by the Unicode Consortium provide much additional information on
the semantics and recommended usages of various characters. They pro-
vide guidelines and algorithms for editing, sorting, comparing, normal-
izing, converting and displaying Unicode strings.
Unicode Under Linux
Under GNU/Linux, the C type wchar_t is a signed 32-bit integer type.
Its values are always interpreted by the C library as UCS code values
(in all locales), a convention that is signaled by the GNU C library to
applications by defining the constant __STDC_ISO_10646__ as specified
in the ISO C99 standard.
UCS/Unicode can be used just like ASCII in input/output streams, termi-
nal communication, plaintext files, filenames, and environment vari-
ables in the ASCII compatible UTF-8 multi-byte encoding. To signal the
use of UTF-8 as the character encoding to all applications, a suitable
locale has to be selected via environment variables (e.g.,
"LANG=en_GB.UTF-8").
The nl_langinfo(CODESET) function returns the name of the selected
encoding. Library functions such as wctomb(3) and mbsrtowcs(3) can be
used to transform the internal wchar_t characters and strings into the
system character encoding and back and wcwidth(3) tells, how many posi-
tions (0–2) the cursor is advanced by the output of a character.
Under Linux, in general only the BMP at implementation level 1 should
be used at the moment. Up to two combining characters per base charac-
ter for certain scripts (in particular Thai) are also supported by some
UTF-8 terminal emulators and ISO 10646 fonts (level 2), but in general
precomposed characters should be preferred where available (Unicode
calls this Normalization Form C).
Private Area
In the BMP, the range 0xe000 to 0xf8ff will never be assigned to any
characters by the standard and is reserved for private usage. For the
Linux community, this private area has been subdivided further into the
range 0xe000 to 0xefff which can be used individually by any end-user
and the Linux zone in the range 0xf000 to 0xf8ff where extensions are
coordinated among all Linux users. The registry of the characters
assigned to the Linux zone is currently maintained by H. Peter Anvin
コロナウイルスの日ごとの感染者数・死者数をグラフ化してみました。どの国が増加傾向にあり、どの国が終息に向かっているかを視覚化しています。
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa