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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Found it. Previous WWW::Mechanize solution works OK because forms, there, are encoded wholesale, each and every name and value, regardless. See 455-457.

With new Net::Async::HTTP code, I was trying to be smart, only encoding those text values which obviously require to be encoded. However, another value, a string, simple uid in hexadecimal, sneaked in, which happens to be utf8::upgraded. Then URI module (used by HTTP::Request::Common) produces the whole url-encoded form data in utf-8, as I understand. I don't know if it's expected and documented behaviour, but it's not what server, processing my forms, understands. So solution is to always loop through and encode everything, as in 455-457 lines mentioned.

use strict; use warnings; use utf8; use feature 'say'; use URI; use Encode 'encode'; use charnames 'cyrillic'; my $uri = URI-> new( 'http:' ); my $ascii_uid_str = 'abc'; # whatever ascii my $high_ascii_octets = encode( 'koi8-r', qq(\N{zhe})); # = chr 214; # (same as above) # whatever, too, but high-ascii $uri-> query_form( $ascii_uid_str, $high_ascii_octets ); say $uri-> query; utf8::upgrade( $ascii_uid_str ); # oops, unexpected $uri-> query_form( $ascii_uid_str, $high_ascii_octets ); say $uri-> query; __END__ abc=%D6 abc=%C3%96

In reply to Re: How to set charset when POSTing? by vr
in thread How to set charset when POSTing? by vr

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-09-28 12:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (124 votes). Check out past polls.

    Notices?