/** * Make a string uppercase * * Use mb_strtoupper() if available, although our workaround does not seem * to be significantly slower. * @param string * @return string */ function utf8_strtoupper($str) { if (USE_MBSTRING) { return mb_strtoupper($str, utf8_detect_encoding($str)); } global $UTF8_LOOKUP_TABLE; if (!is_array($UTF8_LOOKUP_TABLE)) { require_once TL_ROOT . '/system/utf8_lookup.php'; } return strtr($str, $UTF8_LOOKUP_TABLE['strtoupper']); }
function mb_detect_encoding($str) { return utf8_detect_encoding($str); }
/** * Convert character encoding * * Use utf8_decode() to convert UTF-8 to ISO-8859-1, otherwise use iconv() * or mb_convert_encoding(). Return the original string if none of these * libraries is available. * @param string * @param string * @param string * @return string */ function utf8_convert_encoding($str, $to, $from = null) { if (!$str) { return ''; } if (!$from) { $from = utf8_detect_encoding($str); } if ($from == $to) { return $str; } if ($from == 'UTF-8' and $to == 'ISO-8859-1') { return utf8_decode($str); } if ($from == 'ISO-8859-1' and $to == 'UTF-8') { return utf8_encode($str); } if (UTF8_MBSTRING) { @mb_substitute_character('none'); return @mb_convert_encoding($str, $to, $from); } if (function_exists('iconv')) { if (strlen($iconv = @iconv($from, $to . '//IGNORE', $str))) { return $iconv; } return @iconv($from, $to, $str); } return $str; }