What we do in life echoes in eternity!
Home About Me Diary

Convert decode broken cyrillic characters

posted on: 19:57, November 10th , 2007

If you have a bunch of unreadable cyrillic chars like so:

À à Á á Â â Ã ã Ä ä Å å Æ
æ Ç ç È è É é Ê ê Ë ë Ì ì Í í Î î Ï ï

use this script to translate it back to readable:

function transliterate($cyrstr)
$ru = array('À', 'à',
'Á', 'á',
'Â', 'â',
'Ã', 'ã',
'Ä', 'ä',
'Å', 'å',
'Æ', 'æ',
'Ç', 'ç',
'È', 'è',
'É', 'é',
'Ê', 'ê',
'Ë', 'ë',
'Ì', 'ì',
'Í', 'í',
'Î', 'î',
'Ï', 'ï',
'Ð', 'ð',
'Ñ', 'ñ',
'Ò', 'ò',
'Ó', 'ó',
'Ô', 'ô',
'Õ', 'õ',
'Ö', 'ö',
'×', '÷',
'Ø', 'ø',
'Ù', 'ù',
'Ü', 'ü',
'Þ', 'þ',
'ß', 'ÿ',
'Ú', 'ú');

$en = array('А', 'а',
'Б', 'б',
'В', 'в',
'Г', 'г',
'Д', 'д',
'Е', 'е',
'Ж', 'ж',
'З', 'з',
'И', 'и',
'Й', 'й',
'К', 'к',
'Л', 'л',
'М', 'м',
'Н', 'н',
'О', 'о',
'П', 'п',
'Р', 'р',
'С', 'с',
'Т', 'т',
'У', 'у',
'Ф', 'ф',
'Х', 'х',
'Ц', 'ц',
'Ч', 'ч',
'Ш', 'ш',
'Щ', 'щ',
'Ь', 'ь',
'Ю', 'ю',
'Я', 'я',
'Ъ', 'ъ');

return str_replace($ru, $en, $cyrstr);

$file = 'mod3.sql';
$fh = fopen($file, "r");
$file_contents = transliterate(file_get_contents($file));

$file2 = 'db.sql';
$fh2 = fopen($file2, "w");
fwrite($fh2, $file_contents);

echo "DONE!";


Write a comment

*Security code:
*1+2 = (write in words ;)

All materials on this site are licensed under the following license: "Steal every piece of information you can get your hands on and run as fast as you can "