Skip to content

Instantly share code, notes, and snippets.

@halillusion
Last active June 21, 2023 12:52
Show Gist options
  • Save halillusion/a468a46929ba94681431ef7544a5c0fa to your computer and use it in GitHub Desktop.
Save halillusion/a468a46929ba94681431ef7544a5c0fa to your computer and use it in GitHub Desktop.
Turkish Character Fixer
<?php
function turkishCharacterFixer($string)
{
// = <0x9d>
// Some Special Characters
$find = ['•', '“', '”', '‘', '’'];
$repl = ['•', '“', '”', '‘', '’'];
$string = str_replace($find, $repl, $string);
// İ and ı Characters
$find = ['ݾ', 'Ý', 'Ä°', 'Ý', '‹', '&Yacute;', '&Auml;&deg;', '&#304;' ];
$repl = 'İ';
$string = str_replace($find, $repl, $string);
$find = ['ý', 'ı', '±', 'ý', 'Û', '›', '&yacute;', 'ı', '&Auml;&plusmn;', '&#305;'];
$repl = 'ı';
$string = str_replace($find, $repl, $string);
// Ş and ş Characters
$find = [ 'Þ', 'Åž', 'ÅŸ', 'åÿ', '&THORN;', '&Aring;&#158;', '&#350;' ];
$repl = 'Ş';
$string = str_replace( $find, $repl, $string );
$find = [ 'þ', 'Å?', 'ÅŸ', '&thorn;', '&Aring;&#159;', '&#351;' ];
$repl = 'ş';
$string = str_replace($find, $repl, $string);
// Ğ and ğ Characters
$find = [ 'Ð', 'Äž', '&Auml;&#158;', '&#286;' ];
$repl = 'Ğ';
$string = str_replace( $find, $repl, $string );
$find = [ 'ð', 'Ä?', 'ÄŸ', '&eth;', '&Auml;&#159;', '&#287;' ];
$repl = 'ğ';
$string = str_replace($find, $repl, $string);
// Ç and ç Characters
$find = [ 'Ç', '�' ,'&Ccedil;', '&Atilde;&#135;' ];
$repl = 'Ç';
$string = str_replace( $find, $repl, $string );
$find = [ 'ç', '&ccedil;', '&Atilde;&sect;'];
$repl = 'ç';
$string = str_replace($find, $repl, $string);
// Ö and ö Characters
$find = [ 'Ö', '&Ouml;', '&Atilde;&#150;' ];
$repl = 'Ö';
$string = str_replace( $find, $repl, $string );
$find = [ 'ö', '&ouml;', '&Atilde;&para;'];
$repl = 'ö';
$string = str_replace($find, $repl, $string);
// Ü and ü Characters
$find = [ 'Ü', '&Uuml;', '&Atilde;&#156;'];
$repl = 'Ü';
$string = str_replace( $find, $repl, $string );
$find = [ 'ü', 'ã¼', 'ü', '&uuml;', '&Atilde;&frac14;'];
$repl = 'ü';
$string = str_replace($find, $repl, $string);
return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment