如何使json_encode()与ISO-8859-1配合使用(åäö) [英] How to get json_encode() to work with ISO-8859-1 (åäö)
本文介绍了如何使json_encode()与ISO-8859-1配合使用(åäö)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
json_encode()
在使用åäö时对我不起作用.为什么?而我该如何运作呢?
json_encode()
wont work for me when I'm using åäö. Why? And how can I get it to work?
php
:
echo json_encode($arr);
javascript
:
var theResponse = JSON.parse(xmlHttp.responseText);
当我alert()
响应且响应包含å,ä或ö时,响应为= NULL
When I alert()
the response, and the response contains å, ä or ö, the response is = NULL
请帮帮我...
推荐答案
正如Greg所述,我不得不将åäö编码为UTF-8
.但是我没有使用iconv或mbstring.当我将所有值utf8_encode()
放入array
之前,问题就解决了.
As Greg mentioned, I had to encode åäö to UTF-8
. But I did't use iconv or mbstring. When I utf8_encode()
all values before putting the values to the array
the problem was solved.
这篇关于如何使json_encode()与ISO-8859-1配合使用(åäö)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文