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):
à = à
Ó = Ó
ÇÃ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..