Re: [PHP-WIN] UTF8_encode ()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 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 \

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


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux