0

My application is running on Google App Engine/Java

I am trying to pass jQuery Hebrew text (via JSON), although I keep getting question marks (????) instead of the text.

All other text appears well besides Hebrew.

Here is the jQuery code:

        $.ajax({ 
        type: 'POST', 
        url: '/SomeAction.html', 
        data: { status: 'START' },
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        dataType: 'json',
        success: function (data) { 

In the server side I use a Java debugger and I see the Hebrew text well. Here is the code on the server (I use Java/Spring and Jackson)

        objectMapper.setSerializationInclusion(Include.NON_NULL); 
        String json = objectMapper.writeValueAsString(quizPojo);
        response.setContentType("application/json");
        response.setHeader("Content-Type","text/html; charset=utf-8");
        response.setCharacterEncoding("utf-8");
        //logger.warning(json);
        return json;

Appreciate any help,

Uri Lukach
  • 1,093
  • 1
  • 14
  • 28
  • What content-type has the webpage calling the javascript code? Not the java side but the webserver. – getjackx Mar 21 '18 at 12:20
  • Written above, contentType: "application/x-www-form-urlencoded; charset=UTF-8", – Uri Lukach Mar 21 '18 at 12:22
  • Ok first things first. Requests need to use the ["Accept"-Header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept) not Content Type. Second the JavaScript is not related to your Webserver. The webserver may serve the page with the javascript in ISO-12345 even though you want UTF8. Edit: Like ` ....` on your webpage or e.g. [Apache2 configuration](https://stackoverflow.com/questions/913869/how-to-change-the-default-encoding-to-utf-8-for-apache) – getjackx Mar 21 '18 at 12:25
  • Web server should respect the http response content type and charset – Uri Lukach Mar 21 '18 at 12:29
  • I am trying to add to Google App Engine, to change default encoding – Uri Lukach Mar 21 '18 at 23:05

0 Answers0