Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: HTML Form > PERL Script in UTF-8 issue

by Jishanator (Initiate)
on Aug 29, 2012 at 20:39 UTC ( #990560=note: print w/ replies, xml ) Need Help??


in reply to Re: HTML Form > PERL Script in UTF-8 issue
in thread HTML Form > PERL Script in UTF-8 issue

Your graph was very helpful, visualizing it we were able to figure out that the problem was underlying with the decoding of the variable.

$input{'formfieldname'} = Encode::decode('UTF-8', $input{'formfieldname'});

Fixed it right up. Thank you.


Comment on Re^2: HTML Form > PERL Script in UTF-8 issue
Download Code
Re^3: HTML Form > PERL Script in UTF-8 issue
by Your Mother (Canon) on Aug 29, 2012 at 22:31 UTC
    use CGI qw( -utf8 );

    Will do this automatically for you; the caveat being it will cause problems with file uploads. Otherwise it's quite handy.

      This did not work... After thorough research, apparently the problem resides within the STDIN, the variables from the FORM element are always raw, therefore never encoded. To resolve; decode the elements to UTF8. I can't seem to find a "global" method of doing so, so calling a loop that flips through the array of FORM elements will seemingly have to be my fix.

        This does exactly what you describe: decodes to utf-8. It's high time you show a minimal set of code to replicate the problem you're having. It's almost certainly not what you think it is.

Re^3: HTML Form > PERL Script in UTF-8 issue
by remiah (Hermit) on Aug 30, 2012 at 10:29 UTC

    You fixed it , or you didn't fix it. I would recommend to check the version of CGI.pm with command like this.

    perl -MCGI -e 'print $CGI::VERSION'

    From Character Encodings in Perl, which moritz sometimes cites for unicode issue.

    Special care must be taken when reading POST or GET parameters with the function param in the module CGI. Older versions (prior to 3.29) always returned byte strings, newer version return text strings if charset("UTF-8") has been called before, and byte strings otherwise. 
    
    So, it is possible that you use older version of CGI.pm. And one day someone upgrade CGI.pm, you will be in trouble.

    Sometimes, older module has different behavior for decoding. I stumbled with older LWP::Simple and these troubles really embarrass me.

      You got me worried now, I'm not too familiar with these things. I found out I have version 3.55 of CGI.pm. I do have it functioning currently, although I'm not very trusting of it long-term, let alone exactly how it's functioning.
      It's 3.55, I'm not too sure if that's a red flag or not?

        CGI.pm seems to have explicit flag like '-utf8', So, 3.55 may have no problem at all.

        I have no intention to worry you.

        That doc will help you when you have some trouble with unicode, so please read that.

        regards

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://990560]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2014-07-26 13:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (177 votes), past polls