[PHP-users 304] php4.0.6とPostgerSQLでの日本語コードについて!

Morihiko Inamine php-users@php.gr.jp
Wed, 27 Jun 2001 21:02:02 +0900


稲嶺と申します
php4.0.6とPostgreSQL7.1(linux)で
phpのスクリプトはSJISで書き
PostgreSQLのコードはEUC-JPで行きたいと思っているのですが
いざ、WindowsのIEで表示させるとスクリプトのecho();で書いた文字はSJISで表示され
PostgreSQLより取得した日本語はEUC-JPで表示され、文字化けしてしまいます

以下にphpのコードを示します
項目名の"name"には日本語文字列が入っています
<?php
$conn = pg_connect("host=lady port=5432 dbname=swsphpbase user=xxxx password=xxxxx");
$result = pg_exec($conn,"select kind_code,name from t_oskind");
for($x=0;$x < pg_numrows($result);$x++){
   $kind_code=pg_result($result,$x,"kind_code");
   $name     =pg_result($result,$x,"name");
   echo "kind_code[",$x,"]=",$kind_code," name[",$x,"]=",$name, "<BR>\n";
}
pg_close($conn);
?>

PHP.INIの以下の項目を修正してもダメでした
mbstring.internal_encoding = EUC-JP
mbstring.http_input = auto
mbstring.http_output = SJIS
mbstring.detect_order = SJIS

また、phpのconfigureは以下のようになってます
./configure --with-apxs=/usr/local/apache/bin/apxs \n
       --with-pgsql=/usr/local/pgsql \n
       --enable-mbstr-enc-trans --enable-mbstring \n
       --with-pdflib=/usr/local --with-jpeg-dir=/usr \n
       --with-zlib-dir=/usr --with-tiff-dir=/usr \n
       --with-png-dir=/usr --with-zlib=/usr
やはり、正しく表示させる方法としてPostgreSQLから取得した日本語文字列は
1つ1つ文字列変換関数を利用して変換しないといけないのでしょうか?

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
稲嶺盛彦(Morihiko Inamine)
ina@swsys.co.jp
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/