Note in regards to 'rickyale at ig dot com dot br' program:
Wouldn't the whole issue be fixed by using charset=utf-8 in the HTML page?
I'm passing some data between the HTML form and an PHP program - my 'special' characters have to do with the Polish alphabet - and it looks like JavaScript encoding actually... works.
Of course, I could have tested only a limitted number of cases.
Just a thought.