-1

The special characters are not being rendered correctly, they give the black "?" instead.

I have a string which is coming from API response like "Perrier-Jouët" but while displaying on the screen it looks like below

enter image description here

I am already using <meta charset="utf-8" /> in my html

can anyone let me know how to get it rendered correctly?

TIA

ScreenShot of response

screenshot while debugging UI after getting the response

  • 2
    You also have to save your file as UTF-8. Which text editor are you using? – Ry- Oct 01 '19 at 05:29
  • Do you know that the string is being encoded using function like encodeURI(string)? If so, can you try decoding it using decodeURI(string)? – Komal R Oct 01 '19 at 06:09
  • @Ry- I am using VS code. – Vaibhav Jain Oct 01 '19 at 12:06
  • What does the bottom bar say about the file’s encoding? https://stackoverflow.com/questions/30082741/change-the-encoding-of-a-file-in-visual-studio-code Maybe “Latin-1” or something? (Regardless, you should be able to change it this way.) – Ry- Oct 01 '19 at 12:26
  • @KomalR I tried decodeURI(string) still it is not getting render. I still has ? in the string. – Vaibhav Jain Oct 01 '19 at 12:32
  • @Ry- encoding tech is selected as utf-8. – Vaibhav Jain Oct 01 '19 at 12:41
  • @VaibhavJain: Sorry, I missed that it was coming from an API response. We actually need to see your code, then. It’s also possible the API is just returning a bad response – you should check whether that’s the case, maybe by requesting it manually or through another tool that uses the same API. – Ry- Oct 01 '19 at 12:49
  • @Ry- attached response screenshot to the original question. also attached the screenshot while debugging when i get response in the UI code. – Vaibhav Jain Oct 01 '19 at 13:12

1 Answers1

0

I believe convert them to HTML Entities might help you.

https://www.w3schools.com/php/func_string_htmlentities.asp

And use character-set as UTF-8.

Siddharth Jain
  • 118
  • 1
  • 14