Code: Select all
function serendipity_utf8_encode($string) {
if (strtolower(LANG_CHARSET) != 'utf-8') {
if (function_exists('iconv')) {
return iconv(LANG_CHARSET, 'UTF-8', $string);
} else if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, 'UTF-8', LANG_CHARSET);
} else {
return utf8_encode($string);
}
} else {
return $string;
}
}
string iconv ( string in_charset, string out_charset, string str )
Performs a character set conversion on the string str[/] from in_charset to out_charset. Returns the converted string or FALSE on failure.
In order to be safe, serendipity_utf8_encode should check the return value of iconv an fall through on the mb_convert_encoding and/or utf8_encode functions if iconv returns FALSE.