如何在PHP中将UTF8字符串转换为代码页?

时间:2012-06-11 13:56:07

标签: php utf-8

我有一个UTF-8的字符串,并且有代码页(数字)。如何将UTF-8字符串转换为代码页?

2 个答案:

答案 0 :(得分:1)

$string = "äöå"; //File is saved as UTF-8
$codepage = unpack("N*",mb_convert_encoding( $string, "UTF-32BE", "UTF-8" ));

var_dump( $codepage );

//array(3) { [1]=> int(228) [2]=> int(246) [3]=> int(229) }

答案 1 :(得分:1)

好吧,看起来我找到了:

$out = iconv("UTF-8", 'Windows-1252//TRANSLIT//IGNORE', $out);

需要Windows前缀。也很好转换和忽略