C
comopasta Gr
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=C3=B3n
Tom's card
So those two string above contain ' and =C2=B4 spcecial characters.
In the application I need to feed those to a javascript function using
onclick, so I use:
onclick=3D"remove('<%=3D card.name %>')"
Doing it that way, the HTML results in:
onclick=3D"remove('Validaci=C3=B3n')"
onclick=3D"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=3D"remove('<%=3D CGI::escape(tag.name) %>')"
And that results in:
onclick=3D"remove('Tom%27s+card')"
onclick=3D"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=C3=83=C2=B3n
Note the =C3=83=C2=B3
-----
I can't find a way to fix one without breaking the other.
Any suggestions to solve this problem?
Cheers.
-- =
Posted via http://www.ruby-forum.com/.=
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=C3=B3n
Tom's card
So those two string above contain ' and =C2=B4 spcecial characters.
In the application I need to feed those to a javascript function using
onclick, so I use:
onclick=3D"remove('<%=3D card.name %>')"
Doing it that way, the HTML results in:
onclick=3D"remove('Validaci=C3=B3n')"
onclick=3D"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=3D"remove('<%=3D CGI::escape(tag.name) %>')"
And that results in:
onclick=3D"remove('Tom%27s+card')"
onclick=3D"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=C3=83=C2=B3n
Note the =C3=83=C2=B3
-----
I can't find a way to fix one without breaking the other.
Any suggestions to solve this problem?
Cheers.
-- =
Posted via http://www.ruby-forum.com/.=