Fellow Monks, I have an interesting situation with a CGI parameter. I am somewhat convinced it's a character set issue, but not sure what the resolution is. It appears that param is having an issue unencoding the parameter.

I can see in the raw query_string that the encoded string is passing in OK, but when I yank that parm out via CGI->param it's getting hosed. I'd rather not just parse the query_string myself if I don't have to.

Any thoughts on this? I am on an AIX box using Websphere.

given this URL parameter:

/cgi-bin/sidtest?sid=%32%2D%9F%A5%54%12%23%AA%C8%C7%CF%CE%8E%AC
and this code:
#!/ots/perl/bin/perl $|++; use strict; use CGI; my $q = new CGI; my $sid = $q->param("sid"); print "Content-type: text/plain\n\n"; print "\nsid is: $sid\n"; print "\nsid escaped is: " . $q->escape($sid); print "\nsid unescaped is: " . $q->unescape($sid); print "\nENV{QUERY_STRING} is: " . $ENV{QUERY_STRING}; exit;
I am getting this:
sid is: 2-Ÿ¥T#ªÈÇÏÎŽ¬ sid escaped is: 2-%9F%A5T%12%23%AA%C8%C7%CF%CE%8E%AC sid unescaped is: 2-Ÿ¥T#ªÈÇÏÎŽ¬ ENV{QUERY_STRING} is: sid=%32%2D%9F%A5%54%12%23%AA%C8%C7%CF%CE%8E%AC
note that if I execute from the command line, I am seeing similar behavior:
gen31$ ./sidtest sid=%32%2D%9F%A5%54%12%23%AA%C8%C7%CF%CE%8E%AC Content-type: text/plain sid is: 2-¥T#ªÈÇÏά sid escaped is: 2-%9F%A5T%12%23%AA%C8%C7%CF%CE%8E%AC sid unescaped is: 2-¥T#ªÈÇÏά ENV{QUERY_STRING} is:
Any thoughts/clues are most welcome, especially if I am just being a dumbass and not seeing the obvious.

In reply to CGI param character strangeness by wardk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.