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.