mb_convert_encoding
(PHP 4 >= 4.0.6, PHP 5)
mb_convert_encoding — Convert character encoding
说明
string mb_convert_encoding ( string $str , string $to_encoding [, mixed $from_encoding ] )Converts the character encoding of string str to to_encoding from optionally from_encoding.
参数
- str
-
The string being encoded.
- to_encoding
-
The type of encoding that str is being converted to.
- from_encoding
-
Is specified by character code names before conversion. It is either an array, or a comma separated enumerated list. If from_encoding is not specified, the internal encoding will be used.
See supported encodings.
返回值
The encoded string.
范例
Example #1 mb_convert_encoding() example
<?php
$str = mb_convert_encoding($str, "SJIS");
$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");
$str = mb_convert_encoding($str, "UCS-2LE", "JIS, eucjp-win, sjis-win");
$str = mb_convert_encoding($str, "EUC-JP", "auto");
?>
参见
- mb_detect_order() - Set/Get character encoding detection order