Why are Scandinavian characters converted to UTF

I am trying to create an array with Danish characters - why are the characters converted to UTF-8 when output by PHP? Apache's httpd.conf? PHP.ini?

// Fails
$chars = array_merge(range("A","Z"),str_split("ÆØÅ"));
// Observed result: (array) ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ
// Expected result: (array) ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ

// Works
$chars = array_merge(range("A","Z"),str_split(utf8_decode("ÆØÅ")));
// Observed result: (array) ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅ

I have tried to set Content Type and Default Charset to ISO-8859-1 in the document top:

header('Content-type: text/html; charset=ISO-8859-1');
ini_set('default_charset', 'ISO-8859-1');

Content Type is also set in the HTML document (while this is not relevant since the issue occurs in the PHP engine, before HTML is output):

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">


Sorry about answering my own question..

I solved this by changing the file encoding from UTF-8 to ANSI.

链接地址: http://www.djcxy.com/p/25126.html

上一篇: 8个问题PHP / MySQL

下一篇: 为什么斯堪的纳维亚字符转换为UTF