Welcome to WebmasterWorld Guest from 54.163.19.57

Forum Moderators: open

Message Too Old, No Replies

Using escape() without Unicode encoding

Need to use latin1/ISO-8859-1 encoding

     
6:21 pm on Sep 22, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 12, 2005
posts:371
votes: 0


Basically I need to be able to pass a string in a URL. This string may contain ISO-8859-1/latin1 characters, for instance, the single right quote that Word seems to love oh so much. Using the php urlencode() function, this converts it properly to %26%23146%3B, or ’. When I try to use javascript's escape function, I get %u2019. The encoding on the page is ISO-8859-1, so I'm not sure why it's going with the Unicode encoding on it. The URL that it is calling is a Perl script, which interprets this as n ISO-8859-1 encoding, so I end up with some funky characters, ’.

If anyone has any ideas on either what I'm doing wrong or how to fix it, I would very much appreciate it. I thought I pretty much got the whole character encoding thing, but I'm quickly losing faith in that.

Thanks!
Chad

8:45 pm on Sept 22, 2005 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 15, 2004
posts:2047
votes: 0


Have a go with: encodeURIComponent()

(The result ain't so good either, but it might give you a pointer)

9:00 pm on Sept 22, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Apr 12, 2005
posts:371
votes: 0


Thanks for the suggestion.

I gave encodeURIComponent() a try, and I get differently same results. That is, it changes the encoding in the url from %u2019 to %E2%80%99, but still comes across as ’ in my perl script. I was reading somewhere that Unicode is the new standard for URLs, so the answer maybe to get my Perl script to decode it as Unicode instead of ISO-8859-1. Interestingly, I've been testing this in Firefox so far; when I try it in IE, it appears to automatically convert the right single quote to the much more bland, but infinitely more compatible, apostrophe, '.

Chad