Weird, but strtr corrupting chars, if used like below and if file is encoded in UTF-8;
<?php
$str = 'Äbc Äbc';
echo strtr($str, 'Ä', 'a');
?>
And a simple solution;
<?php
function strtr_unicode($str, $a = null, $b = null) {
$translate = $a;
if (!is_array($a) && !is_array($b)) {
$a = (array) $a;
$b = (array) $b;
$translate = array_combine(
array_values($a),
array_values($b)
);
}
return strtr($str, $translate);
}
$str = 'Äbc Äbc';
echo strtr($str, 'Ä', 'a') ."\n";
echo strtr_unicode($str, 'Ä', 'a') ."\n";
echo strtr_unicode($str, array('Ä' => 'a')) ."\n";
?>