[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-i18n
Subject:    [PHP-I18N] mbstring: Japanese: encoding conversion not workingfor me
From:       61.119.142.233
Date:       2002-07-09 6:02:16
[Download RAW message or body]

If this is the wrong list to be writing to someone please point me in
the  right direction, if not ...

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 pgsql 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 using
some of the mbstring library functions.

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 output 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!"(B
$B%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 Internationalization Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic