UTF-8 フラグと戦う人へ 〜Storable の bugfix なんか待ってられない編 - にぽたん研究所

September 24, 2005

このエントリーをはてなブックマークに追加
このあいだ紹介した、Unicode::RecursiveDowngrade ですが、弾さんが、

404 Blog Not Found:UTF-8 Flagを落とそうとして思わぬBugを見つけた話
これじゃ、駄目。
と一言で、一刀両断されてますた。
以下ダメな点を。
  • Hash Keyに未対応
  • Blessed Referenceに未対応
と駄目な点を挙げつつ、Storable モジュールの $Storable::drop_utf8というのを使ったソリューションを公開されてました。
確かに、Storable の perldoc を読むと
Perl 5.6 added support for Unicode characters with code points > 255, and Perl 5.8 has full support for Unicode characters in hash keys. Perl internally encodes strings with these characters using utf8, and Storable serializes them as utf8. By default, if an older version of Perl encounters a utf8 value it cannot represent, it will croak(). To change this behaviour so that Storable deserializes utf8 encoded values as the string of bytes (effectively dropping the is_utf8 flag) set $Storable::drop_utf8 to some TRUE value. This is a form of data loss, because with $drop_utf8 true, it becomes impossible to tell whether the original data was the Unicode string, or a series of bytes that happen to be valid utf8.
とちゃんと明記されています。
いやぁ、これは全然知らんかったですねぇ…。

が、しかし、弾さんが
ダメダメいうだけではダメなので、以下、代案....を出そうとしたら、StorableのBugを見つけてしまったかも。
なんやら、Storable のこのあたりがバグってらっしゃる模様。

で、今日ナニゲに CPAN を散策していたら、Unicode::RecursiveDowngrade が 0.02 にバージョンアップしていますねぇ。
見る限り、弾さんが指摘していた二点も解消されているっぽいです。

ということで、その二点が気になる方は、いつ訪れるかわからない Storable の bugfix を待つよりは、Unicode::RecursiveDowngrade の 0.02 以降を使ったら良さそうです。


ちとモジュール名が長すぎてタイプ量が多いのがアレですが。。。

nipotan at 14:46 | Comments(2) | TrackBack(1)
このエントリーをはてなブックマークに追加

Trackback URL for this entry

Trackbacks

1. Object::Apply  [ 404 Blog Not Found ]   September 24, 2005 21:12
にぽたん、お見事。 UTF-8 フラグと戦う人へ 〜Storable の bugfix なんか待ってられない編 - にぽたん研究所ちとモジュール名が長すぎてタイプ量が多いのがアレですが。。。

Comments

1. Posted by ステキ   September 24, 2005 17:40
UNIVERSAL::isa($val, 'HASH');
なんて書き方もできるよね。
2. Posted by nipotan   September 25, 2005 02:28
おー、それは知らんかったです。
でも総当りでチェックしないといけないですよねぇ。
miyagawa さんから、Scalar::Util の reftype というのがあるという情報ももらいますた。

Post a comment

Name:
URL:
  Remember info?: Rate: Face    Star