Apr 06, 2006

Java の Unicode 4 サポート

Java が Java 5.0 で Unicode 4 にバージョンアップしてたことを最近知った。 Unicode 4 は 1 文字 16bit では表現できないコード体系になっているらしい。 Java は 1 文字 16bit を前提としている言語になっている。 char は 16bit で確保されているし。 Unicode 4 のサポートは結構オオゴトな気がするのだが、どうなっているのだろう。 というわけで、少々調べてみることにした。

JSR-000204 Unicode Supplementary Character Support (Final Release)
http://jcp.org/aboutJava/communityprocess/final/jsr204/index.html
The Java Language Specification
http://java.sun.com/docs/books/jls/index.html
JSR-000204 Unicode Supplementary Character Support (Proposed Final Draft)
http://jcp.org/aboutJava/communityprocess/first/jsr204/index.html
Java プラットフォームにおける補助文字のサポート
http://java.sun.com/developer/technicalArticles/Intl/Supplementary/index_ja.html
Unicode 4.0 の補助文字のサポート Supplementary Char
http://www.javainthebox.net/laboratory/J2SE1.5/MiscAPI/SupplementaryChar/SupplementaryChar.html

Unicode 4 のコード体系

Unicode 3 までの Unicode は 1 文字 16bit で固定されていた。 Unicode 4 では、コード体系が下記の様に拡張されている。

  • 0x0000 - 0xFFFF ・・・ BMP(Basic Multilingual Plane, 基本多言語面)
  • 0x10000 - 0x1FFFFF ・・・ SMP(Supplementary Multilingual Plane, 補助的多言語面)
    • 0x10000 - 0x1FFFF ・・・ Plane 1
    • 0x20000 - 0x2FFFF ・・・ Plane 2
    • 0x30000 - 0x3FFFF ・・・ Plane 3
    • 0x40000 - 0x4FFFF ・・・ Plane 4
    • 0x50000 - 0x5FFFF ・・・ Plane 5
    • 0x60000 - 0x6FFFF ・・・ Plane 6
    • 0x70000 - 0x7FFFF ・・・ Plane 7
    • 0x80000 - 0x8FFFF ・・・ Plane 8
    • 0x90000 - 0x9FFFF ・・・ Plane 9
    • 0xA0000 - 0xAFFFF ・・・ Plane 10
    • 0xB0000 - 0xBFFFF ・・・ Plane 11
    • 0xC0000 - 0xCFFFF ・・・ Plane 12
    • 0xD0000 - 0xDFFFF ・・・ Plane 13
    • 0xE0000 - 0xEFFFF ・・・ Plane 14
    • 0xF0000 - 0xFFFFF ・・・ Plane 15
    • 0x100000 - 0x10FFFF ・・・ Plane 16
というわけで、コード体系が大きく変更されている。 Unicode の Glossary of Unicode Terms にも見慣れない言葉が追加されている。
Supplementary Character
A Unicode encoded character having a supplementary code point.
Supplementary Code Point
A Unicode code point between U+10000 and U+10FFFF.
Supplementary Planes
Planes 1 through 16, consisting of the supplementary code points.
Surrogate Character
A misnomer. It would be an encoded character having a surrogate code point, which is impossible. Do not use this term.
Surrogate Code Point
A Unicode code point in the range U+D800 through U+DFFF. Reserved for use by UTF-16, where a pair of surrogate code units (a high surrogate followed by a low surrogate) “stand in” for a supplementary code point.
Surrogate Pair
A representation for a single abstract character that consists of a sequence of two 16-bit code units, where the first value of the pair is a high-surrogate code unit, and the second is a low-surrogate code unit. (See definition D27 in Section 3.8, Surrogates.)
の辺りは覚えておいた方がよさそうか。

TrackBack ping me at
http://www.in-vitro.jp/blog/index.cgi/Tiger/20060406_01.trackback
Post a comment

writeback message: Ready to post a comment.