39 lines
1.1 KiB
PHP
39 lines
1.1 KiB
PHP
<?php
|
||
/**
|
||
*
|
||
*/
|
||
class Utilities
|
||
{
|
||
function cleanString($text) {
|
||
$utf8 = array(
|
||
'/[áàâãªä]/u' => 'a',
|
||
'/[ÁÀÂÃÄ]/u' => 'A',
|
||
'/[ÍÌÎÏ]/u' => 'I',
|
||
'/[íìîï]/u' => 'i',
|
||
'/[ěéèêë]/u' => 'e',
|
||
'/[ĚÉÈÊË]/u' => 'E',
|
||
'/[óòôõºö]/u' => 'o',
|
||
'/[ÓÒÔÕÖ]/u' => 'O',
|
||
'/[úùûü]/u' => 'u',
|
||
'/[ÚÙÛÜ]/u' => 'U',
|
||
'/Š/' => 'S',
|
||
'/š/' => 's',
|
||
'/Č/' => 'C',
|
||
'/č/' => 'c',
|
||
'/ř/' => 'r',
|
||
'/Ř/' => 'R',
|
||
'/Ý/' => 'Y',
|
||
'/ý/' => 'y',
|
||
'/ç/' => 'c',
|
||
'/Ç/' => 'C',
|
||
'/ñ/' => 'n',
|
||
'/Ñ/' => 'N',
|
||
'/–/' => '-', // UTF-8 hyphen to "normal" hyphen
|
||
'/[’‘‹›‚]/u' => ' ', // Literally a single quote
|
||
'/[“”«»„]/u' => ' ', // Double quote
|
||
'/ /' => ' ', // nonbreaking space (equiv. to 0x160)
|
||
);
|
||
return preg_replace(array_keys($utf8), array_values($utf8), $text);
|
||
}
|
||
}
|