Wednesday, 14 August 2013

Input is not proper UTF-8, indicate encoding

Input is not proper UTF-8, indicate encoding

I am writing a REST API. I fetch data from a database and store it in a
String. Then I send it back to the browser like this:
//fetch data from database
String s = ...
// Prepare it for browser
byte[] data = s.getBytes("UTF-8");
// Send it to browser now
// ...
The data comes from a postgresql database with UTF8 encoding. The data is
stored in a character varying(5000).
When the browser (Chrome) displays the String this error appears:
error on line 29 at column 285: Input is not proper UTF-8, indicate
encoding !
Bytes: 0x19 0x4C 0x29 0x20
The same problem occurs on other browsers.
Here are the headers sent to the browser:
200
Content-Type: application/xhtml+xml;charset=UTF-8
What am I missing ?

No comments:

Post a Comment