PHP and Unicode: A Love at Fifth Sight
from ApacheCon US05。Andrei Zmievskiさんのプレゼン。「私は日本語は分からない」と言いつつ、
$str = '検索オプション';
print_r(strlen($str));
という具合にサンプルコードに日本語がバシバシ含まれていた。でも、「検索オプション」という言葉が出るのはやはりyahooの人だからか?
以下、プレゼンの概要メモ。
- PHP6ネタで、内部エンコーディングをUnicodeにしよう、という話
- 参加人数は20名程度。朝一番(09:00)のセッションだったから?USだったから?
- 文字セット・エンコーディング
- iconvだとエンコーディング変換だけが可能
- mbstringはCJKに対してtailored
- Unicode 4.0
- Goals
- ICU
- international components for unicode
- let there be unicode!
- a control switch called unicode_sematics
- new string types
- unicode_semantics=onで有効化
- filename_encoding, stream-specific encodingが追加される
- ファイル名もしくはディレクトリ名
- script/source encoding
- iniもしくはdeclare()プラグマで指定可能
declare(encoding="iso-8859-1");
$uni = "al";
include "myfile.php";
- fallback_encoding
- encoding変換問題
- 変換エラー時の動作はcustomizable
- stream filter
$fp = fopen(..., 'w');
stream_filter_append($fp, 'unicode.to.utf8');
fputs(...);
- クラス名や変数名にマルチバイト文字が使える
- 使うのか?
- 現状ではCVSツリー内のみにある