Convert a string from one encoding to another.
string $value The string to convert:
string $to The input encoding:
string $from The output encoding:
string The string with the new encoding
RuntimeException if no suitable encoding function is found (iconv or mbstring)
private function convertEncoding($value, $to, $from) {
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($value, $to, $from);
}
elseif (function_exists('iconv')) {
return iconv($from, $to, $value);
}
throw new RuntimeException('No suitable convert encoding function (install the iconv or mbstring extension).');
}