Dealing with incorrect charset from server response

Hi guys,

I retrieve data from a web server which has partly corrupted characters in the response.

I’ve tried the following things:

  • Set Headers and/or ContentType arguments to UTF-8/JSON in Invoke-RestMethod
  • Set [Console]::OutputEncoding = [Text.UTF8Encoding]::UTF8
  • Manually convert the characters by retrieving the bytes and convert it to Latin-1, Windows-1252, UTF-8
  • Changed the ps1 file encoding from UTF-8 to UTF-8 with BOM

None of them worked.
Most of the characters are displayed right but not all of them.
Here are some corrupted examples I get from the server:

沙拉查词
Enhancer for YouTubeâ„¢
Reverso – Translation, dictionary

Google mostly says something about double conversion or misinterpretion UTF-8 as something different (e.g Latin-1) but as I already said, my attempts to fix it didn’t work.
I don’t think I have any relevant code for you. I just need something to convert those corrupted strings (which I can not retrieve in the correct format because the server is broken or I don’t know) to normal characters. Is this even possible?

Thank you in advance!

Hi, welcome to the forum :wave:

Do you see this on every site that you query or just specific sites? Can you share a URL so we can try to replicate the problem?