[PHP-users 20779]出力をSHIFT_JISにするには

KITAO Kaoru kitao @ netcube.jp
2004年 3月 14日 (日) 15:09:20 JST


こんにちは、北尾といいます。
phpからの出力をSHIFT_JISにする方法について、当方の環境で問題がありましたの
で、対策をご存知の方がいらっしゃいましたらご教授ください。

■発生している状況
出力をSHIFT_JISにしたいのですが、どうしてもEUC-JPで出力される。

■環境
OS: Fedora Core 1
web: apache 2.0.48 (Fedoraのパッケージからインストール)
php: php-4.3.4 (Fedoraのパッケージからインストール)

phpのconfigureのオプションは文末につけました。
またapacheの設定で、AddDefaultCharset off を指定しています。

php.iniの設定を以下のようにしています(phpinfoでは設定どおりに表示)。
mbstring.http_input          auto
mbstring.http_output         SJIS
mbstring.internal_encoding   EUC-JP
mbstring.language            Japanese

上記のような設定で、EUC-JPでスクリプトを記述すれば、出力は自動的にSHIFT_JIS
に変換されるものと理解していたのですが、これは誤りでしょうか。
以下のような簡単なスクリプトをEUC-JPで記述しました。

<html><body><?php print("これはテストです"); ?></body></html>

実行結果はEUC-JPで返されました。
apacheからのレスポンスヘッダでは「Content-Type: text/html」です。

私の理解が根本的に間違っていて、全てスクリプトを記述してSHIFT_JISに変換しな
いといけないのでしょうか。

ご教授ください。よろしくお願いします。


■phpのconfigureのオプション
'./configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux' '--target=i386-redhat-linux-gnu' '--program-
prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--
datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--
localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-
file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--enable-force-
cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath' '--enable-inline-optimization' '--with-bz2' '--
with-db4=/usr' '--with-curl' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-
gd' '--enable-gd-native-ttf' '--with-gdbm' '--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-
jpeg-dir=/usr' '--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml' '--with-expat-
dir=/usr' '--with-dom=shared,/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr' '--with-xmlrpc=shared' '--with-
pcre=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath' '--enable-exif' '--enable-ftp' '--enable-magic-
quotes' '--enable-safe-mode' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-discard-path' '--
enable-track-vars' '--enable-trans-sid' '--enable-yp' '--enable-wddx' '--without-oci8' '--with-
pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos' '--with-ldap=shared' '--with-
mysql=shared,/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr' '--with-snmp=shared' '--enable-ucd-snmp-hack' 
'--with-unixODBC=shared' '--enable-memory-limit' '--enable-bcmath' '--enable-shmop' '--enable-calendar' '--
enable-dbx' '--enable-dio' '--enable-mcal' '--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--
with-apxs2=/usr/sbin/apxs' 

-------------------------------------------
   □   KITAO Kaoru (北尾 馨)
  □  CubeWorks Inc, Ibaraki Pref.



PHP-users メーリングリストの案内