I am hoping that someone can help can japanese user input into my pgsql
database ...

I am still having trouble but am sure it is a simple thing; something
about mbstring probably.

I tried to directly insert user input into my DB but I got the following
error:

Warning:  PostgreSQL query failed:  ERROR:  Invalid EUC_JP character
sequence found (0x8140) in /www/htdocs/test.php on line 31

So I assumed that I should first convert user input into EUC-JP.

I wrote some PHP code to do this but my original user input gets mangled.

I am including the output from my test code and the code at the end of
this email.

Can someone spot what my error/problem is?

Jc


PHP ouput as shown in browser (N6.2)
------------------------------------

$_POST["textfield"]      : 111$B$"$$$&$($*!!4A;z$R$i$,$J(B1235
CONVERT "auto" to EUC-JP : 111$B!"!V!"!"!"%r!"%#!"%'!#!#%(%A%5yh%a!"r&%c!"%O(B1235

mb_internal_encoding()   : EUC-JP
mb_detect_order()        : ASCII, JIS, UTF-8, EUC-JP, SJIS

mb_http_input()          : FALSE
mb_http_input():

-----------

input encoding is        : pass



PHP code I wrote:
-----------------

<?php

$input = $_POST["textfield"];

// convert the user input into EUC-JP (detect user's encoding
// automatically)

$new   = mb_convert_encoding($input, "EUC-JP", "auto");

// output original input and converted input to screen
// this doesn't work as the original input gets mangled

echo("<PRE>");
echo("<BR>\$_POST[\"textfield\"]      : ".$input."<BR>");
echo("CONVERT \"auto\" to EUC-JP : ".$new."<BR>");

// the following outputs mbstring settings to the screen
echo("<BR>mb_internal_encoding()   : ".mb_internal_encoding()."<BR>");
echo("mb_detect_order()        : ".implode(", ", mb_detect_order())."<BR>");

// What is the value of the HTTP input conversion?
// I get a return of "false" which is really strange
// it should be "auto" since that is the setting in my
// php.ini file, and also what phpinfo() says

$enc = mb_http_input("P");
if ($enc == false) echo("<BR>mb_http_input()          : FALSE<BR>");
echo("mb_http_input(): $enc<BR>");

echo("<BR>-----------<BR>");

// Here I check to see what encoding PHP thinks the
// input is in. I get a value of "pass" which is alse
// strange since it is not a valid return value!

$interenc = mb_internal_encoding();
$inputenc = mb_convert_variables($interenc, "", $input);

echo("<BR>input encoding is        : ".$inputenc."<BR>");

echo("</PRE>");
?>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to