public static function fixUTF8($text, $option = self::WITHOUT_ICONV)
    {
        if (is_array($text))
        {
            foreach($text as $k => $v)
                $text[$k] = self::fixUTF8($v, $option);
            return $text;
        }
        
        $last = "";
        while ($last <> $text)
        {
            $last = $text;
            $text = self::toUTF8(static::utf8_decode($text, $option));
        }
        $text = self::toUTF8(static::utf8_decode($text, $option));
        return $text;
    }
public static function fixUTF8($text, $option = self::WITHOUT_ICONV)
    {
        if (is_array($text))
        {
            foreach($text as $k => $v)
                $text[$k] = self::fixUTF8($v, $option);
            return $text;
        }
        
        $last = "";
        while ($last <> $text)
        {
            $last = $text;
            $text = self::toUTF8(static::utf8_decode($text, $option));
        }
        $text = self::toUTF8(static::utf8_decode($text, $option));
        return $text;
    }
public static function fixUTF8 ( $ text , $ option = self :: WITHOUT_ICONV ) { if ( is_array ( $ text ) ) { foreach ( $ text as $ k => $ v ) $ text [ $ k ] = self :: fixUTF8 ( $ v , $ option ) ; return $ text ; } $ last = "" ; while ( $ last <> $ text ) { $ last = $ text ; $ text = self :: toUTF8 ( static :: utf8_decode ( $ text , $ option ) ) ; } $ text = self :: toUTF8 ( static :: utf8_decode ( $ text , $ option ) ) ; return $ text ; }
Fix broken UTF-8 text.

@param $text string The text of whic valid UTF-8 should be created
@param $option Can be WITHOUT_ICONV to disable usage of ICONV extension,
or ICONV_TRANSLIT or ICONV_IGNORE to determine what to do
with invalid characters.
@return The fixed UTF-8 text
Fix broken UTF - 8 text .