<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
		xmlns:xhtml="http://www.w3.org/1999/xhtml"
>

<channel>
	<title>Development memo &#187; 文字化け</title>
	<atom:link href="http://officesoya.net/weblog/tag/%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91/feed/" rel="self" type="application/rss+xml" />
	<link>http://officesoya.net/weblog</link>
	<description>Rough Consensus　And Running code</description>
	<lastBuildDate>Mon, 21 Jun 2010 09:22:37 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://officesoya.net/weblog/tag/%e6%96%87%e5%ad%97%e5%8c%96%e3%81%91/feed/" />
		<item>
		<title>php.iniのmbstringで設定した文字コードとスクリプトの文字コードが違う場合の文字化け</title>
		<link>http://officesoya.net/weblog/2009/04/28/phpini/</link>
		<comments>http://officesoya.net/weblog/2009/04/28/phpini/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 11:37:24 +0000</pubDate>
		<dc:creator>soya</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mbstring]]></category>
		<category><![CDATA[php.ini]]></category>
		<category><![CDATA[文字化け]]></category>

		<guid isPermaLink="false">http://officesoya.net/weblog/?p=152</guid>
		<description><![CDATA[だいぶ前に作成したプログラムを久々に動かしてみたところ、EUC-JPで作成されていたため（php.iniの文字コード設定はUTF-8 ）ブラウザで表示されるたびに文字化けが起こる。ブラウザの「表示」→「エンコード」でEU [...]]]></description>
			<content:encoded><![CDATA[<p>だいぶ前に作成したプログラムを久々に動かしてみたところ、EUC-JPで作成されていたため（php.iniの文字コード設定はUTF-8 ）ブラウザで表示されるたびに文字化けが起こる。ブラウザの「表示」→「エンコード」でEUC-JPに直せば問題なく表示できるのだが、ページを遷移したりリロードするたびに直さなくてはならない。</p>
<p>その際のおまじないがこちら。</p>
<pre class="brush: php;">
mb_http_output('EUC-JP');
mb_internal_encoding('EUC-JP');
ini_set(&quot;default_charset&quot;, &quot;EUC-JP&quot;);
</pre>
<p>これをすべてのスクリプトが読み込む部分に記述した。文字コードがphp.iniと合っていたとしても上記のように記述しておくと環境が変わっても文字化けしなくてよいかも、と思った。ちなみにUTF-8の場合は下記のように。</p>
<pre class="brush: php;">
mb_http_output('UTF8');
mb_internal_encoding('UTF8');
ini_set(&quot;default_charset&quot;, &quot;UTF8&quot;);
</pre>
<p>文字化けなんて、もうしない！</p>
]]></content:encoded>
			<wfw:commentRss>http://officesoya.net/weblog/2009/04/28/phpini/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://officesoya.net/weblog/2009/04/28/phpini/" />
	</item>
	</channel>
</rss>
