I have these two strings:
$str1 = \'Ö\';
$str2 = \'Ö\';
$e1 = mb_detect_encoding($str1);
$e2 = mb_detect_encoding($str2);
var_dump($str1);
var_dump($str2);
You could first convert your input to utf-8 using iconv
and then apply your conversion to ASCII. To detect the current encoding you can use mb_detect_encoding
.
$aUTF8 = iconv(mb_detect_encoding($a, 'UTF-8, ISO-8859-1', true), 'UTF-8', $a);
$bUTF8 = iconv(mb_detect_encoding($b, 'UTF-8, ISO-8859-1', true), 'UTF-8', $b);
$aASCII = iconv("utf-8", "ascii//TRANSLIT", $aUTF8);
$bASCII = iconv("utf-8", "ascii//TRANSLIT", $bUTF8);
Please note that you might have to add additional encodings to the encoding list of mb_detect_encoding
.