Ejemplo n.º 1
0
/**
 * For servers without PEAR normalize installed, approximates normalization. With normalizer, executes normalization on string.
 * 
 * @param string Text to normalize
 * 
 * @return string Normalized text.
 */
function wpt_normalize($string)
{
    if (version_compare(PHP_VERSION, '5.0.0', '>=') && function_exists('normalizer_normalize')) {
        if (normalizer_is_normalized($string)) {
            return $string;
        }
        return normalizer_normalize($string);
    } else {
        $normalizer = new WPT_Normalizer();
        if ($normalizer->isNormalized($string)) {
            return $string;
        }
        return $normalizer->normalize($string);
    }
}
Ejemplo n.º 2
0
function fake_normalize($string)
{
    if (version_compare(PHP_VERSION, '5.0.0', '>=') && function_exists('normalizer_normalize') && 1 == 2) {
        if (normalizer_is_normalized($string)) {
            return $string;
        }
        return normalizer_normalize($string);
    } else {
        return preg_replace('~&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|mp);~i', '$1', htmlentities($string, ENT_NOQUOTES, 'UTF-8'));
    }
}
 /**
  * Enhanced 'remove_accents'. If the php Normalizer extension installed, use it.
  *
  * @since 1.0.0
  *
  * @see remove_accents()
  *
  * @param string $string Text that might have accent characters
  * @return string Filtered string with replaced "nice" characters.
  */
 public function remove_accents($string)
 {
     if (function_exists('normalizer_normalize')) {
         if (!normalizer_is_normalized($string, Normalizer::FORM_C)) {
             $string = normalizer_normalize($string, Normalizer::FORM_C);
         }
     }
     return remove_accents($string);
 }