Voting

: six plus one?
(Example: nine)

The Note You're Voting On

MARC13
18 years ago
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.

<< Back to user notes page

To Top