douzhuijing4911 2011-07-04 16:23
浏览 60
已采纳

关于REST API的charset..æøå

How to make æøå work in a response from a REST API?

The response is generated with json_encode() and since the input array must be utf8-encoded the special chars are not readable in the response..

I have tried to set the charset in the content-type header, but still the same!?

Content-type: application/json; charset=utf-8

The special chars as æøå are still not readable!?

response

HTTP/1.1 200 OK
Date: Mon, 04 Jul 2011 16:16:16 GMT
Server: Apache
Content-Length: 91
Connection: close
Content-Type: application/json

{"result":[{"id":9,"name":"hehe \u00e6\u00f8\u00e5","type":0,"vatcode_id":0,"account":10}]}
  • 写回答

1条回答 默认 最新

  • dousha7904 2011-07-04 16:30
    关注

    Everything seems OK in your response. Control characters or non-ASCII characters are encoded by json_encode in the form \uXXXX. There's nothing wrong with that and the client should be able to understand those escape sequences.

    There's also not much you can do about it, unless you want to post-process the output of json_encode.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效