hotsolutions has asked for the wisdom of the Perl Monks concerning the following question:
I get the "Wide Character" error if $mech->content contains UTF-8 data ... It works if the data is ASCII. What am I missing?use WWW::Mechanize; use encoding 'utf-8'; binmode STDOUT, ':utf8'; .... $mech->submit_form(form_name => 'form');
$k =~ s/([\\\"])/\\$1/g; # escape quotes and backslashes if (utf8::is_utf8($v)){ utf8::encode($v); } push(@parts, qq(Content-Disposition: form-data; name="$k"$CRLF$CRLF$v));<< +/
Example form:use WWW::Mechanize; binmode STDOUT, ':utf8'; # Removes 'wide character' warnings $url = "http://localhost/test.cgi"; $mech = WWW::Mechanize->new(); $mech->get($url); if ($mech->success) { if ($mech->form_name( 'frmLookup' )) { $mech->submit_form(form_name => 'frmLookup'); print "Success"; } }
print qq{Status: 200 Content-Type: text/html <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body> <FORM NAME="frmLookup" ACTION="test.cgi" METHOD="Post" ENCTYPE="mult +ipart/form-data"> <INPUT TYPE="text" NAME="test" VALUE="刘"> </FORM> </body> </html>};
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Mechanize/LWP Error "Wide Character in syswrite"
by Anonymous Monk on May 08, 2009 at 08:11 UTC | |
by Anonymous Monk on May 08, 2009 at 08:18 UTC | |
|
Re: Mechanize/LWP Error "Wide Character in syswrite"
by ikegami (Patriarch) on May 08, 2009 at 16:13 UTC |