Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Remove or replace non-koi8 characters from string
- function fixkoi8($string, $unknownChar = '?') {
- // Single quotes
- $search[] = chr(226).chr(128).chr(152);
- $replace[] = "'";
- $search[] = chr(226).chr(128).chr(153);
- $replace[] = "'";
- // Double quotes, 2 variants
- $search[] = chr(226).chr(128).chr(156);
- $replace[] = '"';
- $search[] = chr(226).chr(128).chr(157);
- $replace[] = '"';
- // Long dash
- $search[] = chr(226).chr(128).chr(147);
- $replace[] = '--';
- // Very long dash
- $search[] = chr(226).chr(128).chr(148);
- $replace[] = '---';
- // Wildcard
- $search[] = chr(226).chr(128).chr(162);
- $replace[] = '*';
- // Middle dot
- $search[] = chr(194).chr(183);
- $replace[] = '*';
- // Three dots
- $search[] = chr(226).chr(128).chr(166);
- $replace[] = '...';
- // Numero
- $search[] = chr(226).chr(132).chr(150);
- $replace[] = 'No';
- // Apply Replacements
- $string = str_replace($search, $replace, $string);
- // Remove any non-ASCII Characters
- $string = preg_replace('/[^\x01-\x7FА-Яа-яё]/u', $unknownChar, $string);
- return $string;
- }
Advertisement
Add Comment
Please, Sign In to add comment