views:

296

answers:

2

Hello!

When I encode an array to JSON I get "u00e1" instead of á.

How could I solve the character encoding?

Thanks

+1  A: 

The browser's default encoding is probably Unicode UTF-8. Try <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.

Pierre-Antoine LaFayette
+3  A: 

Your input data is not Unicode. 0xE1 is legacy latin1/ISO-8859-*/Windows-1252 for á. \u00e1 is the JSON/JavaScript to encode that. JSON must use a Unicode encoding.

Solve it by either fixing your input or converting it using something like iconv.

janmoesen