开发者

Why are Scandinavian characters converted to UTF-8?

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 r开发者_开发知识库esult: (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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜