note 76250 added to function.utf8-decode
| From: | MARC13 at osu1 dot php dot net | Date: | Sat, 07 Jul 2007 14:50:28 +0000 |
| Subject: | note 76250 added to function.utf8-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-128284@lists.php.net to get a copy of this message | ||
I did this function to convert data from AJAX call to insert to my database.
It converts UTF-8 from XMLHttpRequest() to ISO-8859-2 that I use in LATIN2 MySQL database.
<?php
function utf2iso($tekst)
{
$nowytekst = str_replace("%u0104","\xA1",$tekst); //Ä
$nowytekst = str_replace("%u0106","\xC6",$nowytekst); //Ä
$nowytekst = str_replace("%u0118","\xCA",$nowytekst); //Ä
$nowytekst = str_replace("%u0141","\xA3",$nowytekst); //Å
$nowytekst = str_replace("%u0143","\xD1",$nowytekst); //Å
$nowytekst = str_replace("%u00D3","\xD3",$nowytekst); //Ã
$nowytekst = str_replace("%u015A","\xA6",$nowytekst); //Å
$nowytekst = str_replace("%u0179","\xAC",$nowytekst); //Ź
$nowytekst = str_replace("%u017B","\xAF",$nowytekst); //Å»
$nowytekst = str_replace("%u0105","\xB1",$nowytekst); //Ä
$nowytekst = str_replace("%u0107","\xE6",$nowytekst); //Ä
$nowytekst = str_replace("%u0119","\xEA",$nowytekst); //Ä
$nowytekst = str_replace("%u0142","\xB3",$nowytekst); //Å
$nowytekst = str_replace("%u0144","\xF1",$nowytekst); //Å
$nowytekst = str_replace("%u00D4","\xF3",$nowytekst); //ó
$nowytekst = str_replace("%u015B","\xB6",$nowytekst); //Å
$nowytekst = str_replace("%u017A","\xBC",$nowytekst); //ź
$nowytekst = str_replace("%u017C","\xBF",$nowytekst); //ż
return ($nowytekst);
}
?>
In my case also the code file that deals with AJAX calls must be in UTF-8 coding.
----
Server IP: 82.160.108.140
Probable Submitter: 212.76.33.102
----
Manual Page -- http://www.php.net/manual/en/function.utf8-decode.php
Edit -- https://master.php.net/note/edit/76250
Del: integrated -- https://master.php.net/note/delete/76250/integrated
Del: useless -- https://master.php.net/note/delete/76250/useless
Del: bad code -- https://master.php.net/note/delete/76250/bad+code
Del: spam -- https://master.php.net/note/delete/76250/spam
Del: non-english -- https://master.php.net/note/delete/76250/non-english
Del: in docs -- https://master.php.net/note/delete/76250/in+docs
Del: other reasons-- https://master.php.net/note/delete/76250
Reject -- https://master.php.net/note/reject/76250
Search -- https://master.php.net/manage/user-notes.php