php - DBCS not saving properly -


i have edit.php file allow me edit contents of web form. text stored in .txt files. problem comes when try enter characters in japanese, or korean etc.

i input this: "たんじょびおめでとう"

and once save it, returns this: "%u305f%u3093%u3058%u3087%u3073%u304a%u3081%u3067%u3068%u3046"

does 1 have ideas how have characters saved correctly. find if change encoding on .txt files utf-8 , input characters using notepad rather through edit.php tends save fine, though i'd rather not have this.

thanks help!

edit
wasn't sure code put, i'm assuming it's way of saving. here save.php file:

$content = $_post['content'];   if($content == ''){    echo "you cannot null field, please reload page.";   } else {     echo $content;     $myfile = "text/".$_post['id'].".txt";     $fh = fopen($myfile, 'w') or die("could not update");     fwrite($fh,$content);     fclose($fh);   } 

you'll need check character encoding you're inputing (probably iso 8859-1 or cp 1252 on windows).

in case, transforming returned string desired output encoding should easy, string:

%u305f%u3093%u3058%u3087%u3073%u304a%u3081%u3067%u3068%u3046

are 10 unicode escape sequences (utf-8) japanese have entered ("happy birthday"). when input them directly text file, i'm assuming application setting encoding correctly.

if it's web form, check encoding set in request header, example:

content-type    text/xml;charset=utf-8 

Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -