From: "NARUSE, Yui" Date: 2008-01-23T13:28:38+09:00 Subject: [ruby-dev:33299] Re: Binary String 成瀬です。 Tanaka Akira wrote: > In article , > Yukihiro Matsumoto writes: > >> 取り出した情報(コードポイント)がエンコーディング情報を持たな >> いのが気になって文字列を返すようにしたような記憶があります。 > > あと、combining character ですかねぇ。 > > combining character を 1文字とする encoding をあきらめるので > あればいいのかもしれませんが、あきらめないとすれば簡単ではあ > りません。 > > たとえば、JIS X 0213 で導入された文字には Unicode で > combining character にせざるをえない文字 (アイヌ語のとか) が > あるので、そういう文字をどういう整数にするかが問題です。 > > まぁ、Ruby 上なら Bignum がつかえるから問題ないだろう、とい > う考えもありますが、C レベルとどう対応させるかという話は出て > きますな。 「文字」の定義は様々であるところ、Unicode Glossary を引くと、 Character. (1) The smallest component of written language that has semantic value; refers to the abstract meaning and/or shape, rather than a specific shape (see also glyph), though in code tables some form of visual representation is essential for the reader’s understanding. (2) Synonym for abstract character. (3) The basic unit of encoding for the Unicode character encoding. (4) The English name for the ideographic written elements of Chinese origin. [See ideograph (2).] とあるのですが、「combining character を 1文字とする」というのは (2) abstract character ですよね。Ruby がサポートするのは (3) でいいと思います。 つまり、 1-04-87 <304B, 309A> # [HIRAGANA LETTER BIDAKUON NGA] の場合なら、"\u304B\u309A"[1] => 0x309A で。 今のままでも \u309A が返ってきてしまいますが、その辺はもう一つ上のレイ ヤーで何とかする話でしょうねぇ。 # いや、EUC-JIS-2004 を使えって話?(ぉ -- NARUSE, Yui DBDB A476 FDBD 9450 02CD 0EFC BCE3 C388 472E C1EA