Re: UTF8_encode ()

From: Date: Sun, 31 Aug 2003 19:22:36 +0000
Subject: Re: UTF8_encode ()
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-21288@lists.php.net to get a copy of this message
> For testing I set up two pages, one with iso-8859-1 encoding that has a form > with textbox and submit button and another using utf-8 encoding with echoing > utf8_ecnode ();ed text written in the textbox in the first page. > > When I write English it works, Russian - works, German - major screw up, > Lithuanian (my language) - screw up. And so I dunno what to do. I really > need that to work for my multilanguage project I am working on. I googled > for any useful info but only found more ppl having more trouble :/ I use iconv for this: === echo iconv("ISO-8859-2","UTF8",$text); === In my multilanguage sites I use something like that: === $charset=explode(";",$_SERVER['HTTP_ACCEPT_CHARSET']); $charset=explode(",",$charset[0]); $charset=$charset[0]; iconv_set_encoding("internal_encoding", "utf-8"); iconv_set_encoding("input_encoding", $charset); iconv_set_encoding("output_encoding", $charset."//TRANSLIT"); ob_start("ob_iconv_handler"); foreach(array_keys($_POST) as $key) $POST[iconv($charset,"utf-8",$key)]=iconv($charset,"utf-8",$_POST[$key]); $_POST=$POST; foreach(array_keys($_GET) as $key) $GET[iconv($charset,"utf-8",$key)]=iconv($charset,"utf-8",$_GET[$key]); $_GET=$GET; include("html/main.php"); ob_end_flush(); === It translates input data from browser encoding into utf8 and encodes it back from utf8 output to browser encoding. All is done transparently. All data I keep in utf8. BR -- \ Grzegorz Godlewski / / Mail: ggodlewski@pld-linux.org GG: 1600799 ICQ UIN: 118261503 \

« previous php.windows (#21288) next »