boboson has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to get IE7 and FireFox 2 to output the same result when encoding the PATH_INFO environment variable. The URL will look something like:
http://domainname.com/homes/Test boende & Stöd- och rådgivningscenter
I am encoding the above string with the below code:
use Unicode::String qw(utf8 latin1); use URI::Escape; print "Content-type: text/html\n\n"; my @values = split('/', $ENV{PATH_INFO}); my $utf8 = Unicode::String->new( $values[1] ); print "utf8:".$utf8."<br />"; my $latin1 = Unicode::String::latin1($utf8); print "latin1:".$latin1."<br />"; # Works in IE my $unescapeIE = uri_unescape($latin1); print "unescapeIE:".$unescapeIE."<br />"; # works in FireFOx my $unescapeFF = uri_unescape($values[1]); print "unescapeFF:".$unescapeFF."<br />";
in IE7 I receive the following output:
utf8:/Test boende & Stöd- och rÃ¥dgivningscenter latin1:/Test boende & Stöd- och rådgivningscenter unescapeIE:/Test boende & Stöd- och rådgivningscenter unescapeFF:/Test boende & Stöd- och rÃ¥dgivningscenter
The third line is what I want
in FF2 I receive the following output:
utf8:/Test boende & Std- och rdgivningscenter latin1:/Test boende & Std- och rdgivningscenter unescapeIE:/Test boende & Std- och rdgivningscenter unescapeFF:/Test boende & Stöd- och rådgivningscenter
The fourth line is what I want
If I put the string directly in a variable:
my $value = "Test boende & Stöd- och rådgivningscenter";
I receive the same output in both browsers
utf8:Test boende & Std- och rdgivningscenter latin1:Test boende & Std- och rdgivningscenter unescapeIE:Test boende & Std- och rdgivningscenter unescapeFF:Test boende & Stöd- och rådgivningscenter
The fourth line will be correct in both IE7 and FF2, but I need to encode the string from the URL.
Could anyone point me in the right direction, because I am clearly doing something wrong.

Replies are listed 'Best First'.
Re: uri_unescape differences in IE7 and FF2?
by f00li5h (Chaplain) on Apr 12, 2007 at 02:32 UTC

    What happens if you write the decoded strings to a text file on the server? I suspect that IE's may just borking when it comes to actually displaying the text in the browser window.

    @_=qw; ask f00li5h to appear and remain for a moment of pretend better than a lifetime;;s;;@_[map hex,split'',B204316D8C2A4516DE];;y/05/os/&print;
      I am trying to use the variable in an SQL statement later in the code and it seems like I am getting the same value as the outputted value.