Joomla!, Wordpress tips for building your site

Note support UTF-8 in PHP

Published on| July 17th, 2009 | No Comment.

You can very easily create a WEB application by PHP language.
Also, you should not write web page by local code like ShiftJis CODE now.
So, you will not be able to write web page by local code like EUC CODE on Linux.
Because Linux OS supported UTF-8(Unicode) for Web pages.
So, writing the WEB application program with UTF-8 now is becoming usual.

Also PHP language supported UTF-8. But problem that UTF-8 and Ascii can be mixed remain.
In other words, this problem is no problem in the English-speaking, and it is problem in East Asian.
So, if you do not select correct code, your page will not be able to display correct in East Asian.

A simple example is the size of the characters.
If your site was written by English and PHP language, you may use byte size for control charactors.
But your site was written by East Asia local language and PHP language, you will not be able to use byte size for control charactors.
So, you should use charactor size.

Example,

if(strlen($content) > 128){
     $content =  substr($content, 0, 128);
}

In the above code, you will not display correct (characters of 127,128 bytes). Because its code controls characters by byte size.
If you control characters like follows, you will be able to display correct.

if(mb_strlen($content,'UTF-8') > 128){
    $content =  mb_substr($content, 0, 128,'UTF-8') ;
}

It is very basic PHP usage. ()






Comments

Leave a Reply








Transrator

Recent Posts

Categories

Tag Cloud

execute remove フロントページ 投稿ページ トップページ install WIndows Note Convert META generator 日付 donwload file manage multibyte utf-8 unicode shiftjis euc console サイトマップ 問題 ParmaLink Redirect パーマリンク はみ出る pre テンプレート テーマ タグクラウド マルチランゲージ リダイレクト PHP(タグ) タグ table control HTML(タグ) コマンド 国際化(翻訳) SQLite(タグ) MySQL(タグ) qTranslate プラグイン(タグ) Wordpress(タグ)

Links

Site Description

Joomla!, Wordpress as CMS using a site building, site management, software usage to describe the development tips.

  • はてなブックマークへ追加する
  • Facebookでシェアする
  • twitter でつぶやく
  • Google Plusでシェアする
  • Pocketでシェアする
ページトップへ