[Codeigniter-users] 日本語版作成について

Back to archive index

Kenichi Ando(Neo,Inc) ando****@neo-n*****
2007年 11月 27日 (火) 18:29:33 JST


bossatamaです。

On Tue, 27 Nov 2007 18:01:14 +0900
木下 敏夫 <kino****@tktoo*****> wrote:

> 木下です。
> 
> 例えばGeeklogでは
> mb_系のコードに単純に置き換えてしまうと対応していないサーバーの場合に
> 問題になるので下記のようなmb_系と置き換えられるようなコード群を詰め込んだ
> lib-mbyte.php というファイルが用意されていて共通プログラムの最初の方で
> 読み込む様になっています。
> 
なるほど。非常に参考になります。
抜粋頂き、ありがとうございました。

> 
> ----------------------------------------------------------------
> // replacement functions for UTF-8 functions
> function MBYTE_checkEnabled() {
>     static $mb_enabled;
>     if (function_exists( 'mb_eregi_replace' )) {
>         $mb_enabled = mb_internal_encoding("UTF-8");
>     } else {
>         $mb_enabled = false;
>     }
>     return $mb_enabled;
> }
> 
> 
> function MBYTE_strlen($str) {
>     static $mb_enabled;
>     if (!isset($mb_enabled)) {
>         $mb_enabled = MBYTE_checkEnabled();
>     }
>     if ($mb_enabled) {
>         $result = mb_strlen($str);
>     } else {
>         $result = strlen($str);
>     }
>     return $result;
> }
> 
> function MBYTE_substr($str, $start, $length = NULL) {
>     static $mb_enabled;
>     if (!isset($mb_enabled)) {
>         $mb_enabled = MBYTE_checkEnabled();
>     }
>     if ($mb_enabled) {
>         if( $length === NULL )
>         {
>             $result = mb_substr($str, $start);
>         } else {
>             $result = mb_substr($str, $start, $length);
>         }
>     } else {
>         if( $length === NULL )
>         {
>             $result = substr($str, $start);
>         } else {
>             $result = substr($str, $start, $length);
>         }
>     }
>     return $result;
> }
> ----------------------------------------------------------------
> 
> 
> また、ZenCartの場合は mbstring emulator
> https://sourceforge.jp/projects/mbemulator/
> も同梱して日本語処理が確実に行えるようになっています。
> 
> 処理速度を考えると mb系の関数が定義されていない時だけ
> mbstring emulator を読み込んで処理するようにコードを追加した上で
> mb_系に書き換え必要のある関数を順次書き換える後者の形式の方が
> 適しているかもしれません。

mbstring emulator知りませんでした。
CIにはスピードを計るベンチマークツールが標準で入っていますので、
検証したら面白いかもしれないですね。
CIのプロファイリング
http://userguide.cilab.info/general/profiling.html

情報ありがとうございました。

> -- 
> 木下敏夫
> http://www.tktools.jp/
> mailto:kino****@tktoo*****


bossatama
http://codeigniter.jp/




Codeigniter-users メーリングリストの案内
Back to archive index