Hi,
I working on an application that is localized in several languages and
I'm facing some problems with special characters.
I have a name field that can take inputs such as:
Validación
Tom's card
So those two string above contain ' and ´ spcecial characters.
In the application I need to feed those to a javascript function using
onclick, so I use:
onclick="remove('<%= card.name %>')"
Doing it that way, the HTML results in:
onclick="remove('Validación')"
onclick="remove('Tom's card')"
You can see that the first one is ok, but the second on is not because
of the ' in between the m and the s which causes the javascript
to fail.
To avoid that I can use:
onclick="remove('<%= CGI::escape(tag.name) %>')"
And that results in:
onclick="remove('Tom%27s+card')"
onclick="remove('Validaci%C3%B3n')"
The name in the remove function is used to show a confimation so I have
show the name back to the user.
So I use javascript method unescape(card_name.replace(/\+/g, " ")) to
convert the %27 and + back to ' and space to show the original. And that
goes ok.
BUT now the other one is converted to Validaci³n
Note the ³
-----
I can't find a way to fix one without breaking the other.
Any suggestions to solve this problem?
Cheers.