<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>MT312 &#187; 2007 &#187; 8 月</title>
	<link>http://www.mt312.com</link>
	<description></description>
	<pubDate>Mon, 12 May 2008 02:56:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>ja</language>
			<item>
		<title>DoCoMo絵文字データ保存方法</title>
		<link>http://www.mt312.com/php/43/</link>
		<comments>http://www.mt312.com/php/43/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 04:00:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.mt312.com/php/43/</guid>
		<description><![CDATA[携帯から入力された絵文字の判定を簡単に行う方法があるようです。mb_substitute_character();を使って存在しない文字コードを炙り出します。
携帯端末からの投稿を保存
PLAIN TEXT
PHP:




// 出力文字エンコーディングに文字コードが存在しない場合の代替文字を指定


mb_substitute_character&#40;'long'&#41;;


&#160;


// 太陽絵文字入り文字列


$str = '今日も暑いですね・';


// 強制的に絵文字部分がBAD+16進コードに変換される


$str = mb_convert_encoding&#40;$str, mb_internal_encoding&#40;&#41;&#41;;


// 絵文字を[d:絵文字コード]に変換して保存


$str = preg_replace&#40;'/BAD\+(F[89][0-F]{2})/', '[d:$1]', $str&#41;; 






こうしておけば[d:～]を探して変換すれば、PCには絵文字画像、携帯には直接絵文字を表示させる事ができる。記事の修正が必要になっても絵文字を意識しなくて済みます。
保存ログを携帯端末へ出力
PLAIN TEXT
PHP:




$str = '今日も暑いですね[d:F8A0]';


$str = preg_replace&#40;'/\[d:(F[89][0-F]{2})\]/e', "pack('H*', $1)", $str&#41;;


print $str; 






まとめ
BAD+からF3、F4、F6、F7で始まる文字列を調査すれはAU絵文字も判別可能らしい。めちゃくちゃ楽だな、これ。
参考文献
絵文字の抽出をPHPで最も簡単にする方法 ぎじゅっやさん
]]></description>
			<content:encoded><![CDATA[<p>携帯から入力された絵文字の判定を簡単に行う方法があるようです。mb_substitute_character();を使って存在しない文字コードを炙り出します。</p>
<h3>携帯端末からの投稿を保存</h3>
<div class="igBar"><span id="lphp-3"><a href="#" onclick="javascript:showCodeTxt('php-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-3">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#F27900;">// 出力文字エンコーディングに文字コードが存在しない場合の代替文字を指定</span></div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mb_substitute_character"><span style="color:#0000CC;">mb_substitute_character</span></a><span style="color:#006600;">&#40;</span><span style="color:#990000;">'long'</span><span style="color:#006600;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#F27900;">// 太陽絵文字入り文字列</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000CC;">$str</span> = <span style="color:#990000;">'今日も暑いですね・'</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#F27900;">// 強制的に絵文字部分がBAD+16進コードに変換される</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000CC;">$str</span> = <a href="http://www.php.net/mb_convert_encoding"><span style="color:#0000CC;">mb_convert_encoding</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000CC;">$str</span>, <a href="http://www.php.net/mb_internal_encoding"><span style="color:#0000CC;">mb_internal_encoding</span></a><span style="color:#006600;">&#40;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#F27900;">// 絵文字を[d:絵文字コード]に変換して保存</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000CC;">$str</span> = <a href="http://www.php.net/preg_replace"><span style="color:#0000CC;">preg_replace</span></a><span style="color:#006600;">&#40;</span><span style="color:#990000;">'/BAD<span style="color:#990000;">\+</span>(F[89][0-F]{2})/'</span>, <span style="color:#990000;">'[d:$1]'</span>, <span style="color:#0000CC;">$str</span><span style="color:#006600;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>こうしておけば[d:～]を探して変換すれば、PCには絵文字画像、携帯には直接絵文字を表示させる事ができる。記事の修正が必要になっても絵文字を意識しなくて済みます。</p>
<h3>保存ログを携帯端末へ出力</h3>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000CC;">$str</span> = <span style="color:#990000;">'今日も暑いですね[d:F8A0]'</span>;</div>
</li>
<li style="font-weight: bold;color:IG_LINE_COLOUR_2;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000CC;">$str</span> = <a href="http://www.php.net/preg_replace"><span style="color:#0000CC;">preg_replace</span></a><span style="color:#006600;">&#40;</span><span style="color:#990000;">'/<span style="color:#990000;">\[</span>d:(F[89][0-F]{2})<span style="color:#990000;">\]</span>/e'</span>, <span style="color:#990000;">"pack('H*', $1)"</span>, <span style="color:#0000CC;">$str</span><span style="color:#006600;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:IG_LINE_COLOUR_1;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/print"><span style="color:#0000CC;">print</span></a> <span style="color:#0000CC;">$str</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<h3>まとめ</h3>
<p>BAD+からF3、F4、F6、F7で始まる文字列を調査すれはAU絵文字も判別可能らしい。めちゃくちゃ楽だな、これ。</p>
<h3>参考文献</h3>
<p><a href="http://hain.jp/index.php/tech-j/2006/09/11/%E6%90%BA%E5%B8%AF%E7%B5%B5%E6%96%87%E5%AD%97">絵文字の抽出をPHPで最も簡単にする方法 ぎじゅっやさん</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mt312.com/php/43/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
