Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

200
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda