clarkk
clarkk

Reputation: 27685

charset on REST API.. æøå

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}]}

Upvotes: 0

Views: 1867

Answers (1)

Artefacto
Artefacto

Reputation: 97815

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.

Upvotes: 1

Related Questions