Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

199
Views
Decoding "unknown" strings to UTF-8 with Javascript

I have a text source that sends me encoded Strings, for the most part, the JavaScript function decodeURIComponent(escape(str)) works, But I've logged some weird "unknown" characters that broke the decodeURIComponent function, for now I have a workaround with replaceAll:

function fixWeirdCharacters(str){
  return str.replaceAll('à', "a").replaceAll('Ó','O').replaceAll('ÇÃO','CAO').replaceAll('Ú','U').replaceAll('ÃÂ','A').replaceAll('ó','o').replaceAll('ÇÕ','CO').replaceAll('É','E');
}

the following characters gave me error so far (encoded character = expected string):

Ã&nbsp = à
Ó = Ó
ÇÃO = ÇÂO
Ú = Ú
à= ó = ó
ÇÕ = ÇÕ
É = É

the assumption of the correct character was made by looking at the entire word, the main purpose is to decode it to UTF-8 and use it on regular HTML 5 page

Any idea of what might be creating those characters or how to decode them properly using JavaScript only?

Obs: I tried to decode them on PHP using urldecode(), and the result is an "?" box character..

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!