skip to Main Content

I have Ajax call which return JSON in response, Backend is written in servlet, and I have set content-type and character-set as well

response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");

But in Ajax response , I see gibberish character like Bullet turns into � .

Any idea why this is happening?

Thanks in Advance.

3

Answers


  1. This is a replacement character:

    It is used to indicate problems when a system is unable to render a stream of data to a correct symbol. It is usually seen when the data is invalid and does not match any character

    https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character

    Login or Signup to reply.
  2. Don’t use bullet directly. Use the equivalent hexcode or html code and it should work.

    The browser/DOM doesn’t identify some characters. Check the link below:

    https://www.toptal.com/designers/htmlarrows/punctuation/bullet/

    Login or Signup to reply.
  3. Possible solutions to this problem can be :

    1. Setting the response with appropriate charset in the backend layer.
    2. Setting appropriate charset on view/frontend layer.
    3. Setting appropriate charset on the database layer.

    In my case, it was utf8 [or you can use utf8mb4 based on your needs].

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search