Even when i type
echo strtr("-äåö-", "äåö", "xxx");
it does not work properly it outputs this >xxx¥x¶<
, however when i use example below it does not translate nothing at all it keeps original mambo jumbo.
If i type in form ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑŐŰÜÒÓÔÕÖØÝߟàáâãäåçèéêëìíîïñòóôõőöøšűùúûüýÿž
and click translate it outpputs the same string and æ œ
does not translate at all.
<form method="POST">
<input style="width:500px;" type="text" name="first_name" />
<input style="width:500px;" type="text" name="last_name" />
<input type="submit" name="submit" value="translate" />
</form>
<?php
$dict = array(
"Æ" => "AE",
"æ" => "ae",
"Œ" => "OE",
"œ" => "oe"
);
$first = strtr($_POST['first_name'], $dict);
$last = strtr($_POST['last_name'], $dict);
$first = strtr($first,
"ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑŐŰÜÒÓÔÕÖØÝߟàáâãäåçèéêëìíîïñòóôõőöøšűùúûüýÿž",
"AAAAAACEEEEIIIINOUUOOOOOOYSYaaaaaaceeeeiiiinooooooosuuuuuyyz");
$last = strtr($last,
"ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÑŐŰÜÒÓÔÕÖØÝߟàáâãäåçèéêëìíîïñòóôõőöøšűùúûüýÿž",
"AAAAAACEEEEIIIINOUUOOOOOOYSYaaaaaaceeeeiiiinooooooosuuuuuyyz");
echo $first." --- ";
echo $last;
?>
even when i added on top of code
foreach ($_POST as $key => $value) {
$POST[$key] = iconv(mb_detect_encoding($_POST["first_name"]), "ASCII//TRANSLIT", $POST[$value]);
}
and paste AAAAAACEEEEIIIINOUUOOOOOOYSYaaaaaaceeeeiiiinooooooosuuuuuyyz
it comes out like this yAyAyAyEyEyIyIyNyUyOyOyOyYyYyayauaueyeyiyiynyoyoyoysyuuuyyyzy�y�y�y�y�y�y�y�y�y�y�y�y�y�y�y�y�y�uay�yuuzu�y�y�y�y�y�y�u�
Never mind since no one knows why it does not work i just used str_replace
and str_ireplace
very successfully without need for any concerns about encoding.
EDIT: my bad encoding does matter for str_replace too. i used on html page
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />