Reputation: 26402
I'm unescaping an ®
(registration character) in firefox to be submitted in a form, since actually typing that character into Javascript causes the script to behave strangely.
However, I must use the unescaped(..) version of the character since it is being submitted to the backend (where I have no control) and the output is a pdf file which uses the unescaped ®
for display in a pdf.
I unescape the ®
character like this:
unescape("%AE")
However...when I do view the ®
in the pdf file it appears as ®
, this only happens in Firefox, not in Internet Explorer.
Is there anyway of getting this to work in Firefox 2/3?
Thanks,
Andrew
Upvotes: 0
Views: 1032
Reputation: 26322
AFAIK, after unescaping, Mozilla returns the Unicode representation of ®
, but IE not. ("%C2%AE" in hex, and %C2
means that strange character Â
appearing in the PDF.) Internet Explorer and Mozilla unescapes strings in a different way. You should set an explicit character encoding, principally UTF-8.
MDC: escape and unescape Functions:
The escape and unescape functions do not work properly for non-ASCII characters and have been deprecated. In JavaScript 1.5 and later, use encodeURI, decodeURI, encodeURIComponent, and decodeURIComponent.
MSDN:
The unescape method returns a string value that contains the contents of charstring. All characters encoded with the %xx hexadecimal form are replaced by their ASCII character set equivalents.
Characters encoded in %uxxxx format (Unicode characters) are replaced with the Unicode character with hexadecimal encoding xxxx.
Upvotes: 3