Emo PHP携帯絵文字ライブラリ
Home > utf-8で入出力
はじめに
デフォルトはsjisの設定になっていますが、utf-8での入力に変更することも可能になっています。

絵文字を使用するページを作成する際はsjisで表示しないと絵文字が(欠損 or 文字化け)する端末(昔の端末など)があります。
好んでutf-8入出力で作成されないほうがいいと思われますが、それでもutf-8で入出力させたい人は以下をご覧ください。
utf-8で入出力
以下のスクリプトを作成します。
コード中の $this->type~ で文字コードを設定します。

MyEmoUTF8.php
<?php
require_once(dirname(__FILE__) . "/Emo-x.x.x/libs/Emo.php");

class MyEmoUTF8 extends Emo
{
function MyEmoUTF8()
{
/**
* 各キャリアの絵文字の文字コード
* 右に設定値一覧を示す。(*)がデフォルト
*/
$this->type_set_docomo = "utf-8"; // sjis(*), utf-8
$this->type_get_docomo = "utf-8"; // sjis(*), utf-8
$this->type_set_EZweb = "utf-8"; // sjis(*), utf-8
$this->type_get_EZweb = "utf-8"; // sjis(*), utf-8, tag
$this->type_set_SoftBank = "utf-8"; // web(*), sjis, utf-8
$this->type_get_SoftBank = "utf-8"; // web(*), sjis, utf-8
$this->type_set_Voda3G = "utf-8"; // web(*), sjis, utf-8
$this->type_get_Voda3G = "utf-8"; // web(*), sjis, utf-8

/**
* 各キャリアの文字コード
* 右に設定値一覧を示す。(*)がデフォルト
*/
$this->type_in_docomo = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_out_docomo = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_in_EZweb = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_out_EZweb = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_in_SoftBank = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_out_SoftBank = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_in_Voda3G = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_out_Voda3G = "utf-8"; // sjis(*), utf-8, euc-jp, 他
$this->type_in_pc = "utf-8"; // sjis(*), utf-8, euc-jp, 他 pc時html入力
$this->type_out_pc = "utf-8"; // sjis(*), utf-8, euc-jp, 他 pc時html出力 支援ツールhtml

/**
* 呼び出し元の文字コード
* 右に設定値一覧を示す。(*)がデフォルト
*/
$this->type_get_base = "utf-8"; // sjis(*), utf-8, euc-jp, 他 入力変換で使用
$this->type_set_base = "utf-8"; // sjis(*), utf-8, euc-jp, 他 出力変換で使用

$this->Emo();

}
}
?>

後はカスタマイズ項目で説明したように、Emoを継承しているMyEmoUTF8を呼び出して使えばutf-8で入出力できます。
MyEmoUTF8って何?って思った人は、カスタマイズ項目で設定したMyEmoのutf-8バージョンとお考え下さい。
ホームへ