I'm afraid this question is OT -- not really Perl, but web basics.

With WWW::Mechanize, I could get the form from page with e.g. form_name, then just set required charset (accept_charset) and then it all "automatically" worked as expected: set input fields text values (field) using usual "normal" (Unicode) Perl strings, click submit button, and job's done.

Now I'm moving from WWW::Mechanize to Net::Async::HTTP, its POST method accepts array reference of "field_name" => "value" pairs. Here I tried different combinations of encoding text field values (or not encoding at all) and also providing things like

content_type => 'application/x-www-form-urlencoded; charset=utf-8',

as additional %args to POST, but to no avail: reading back what I posted, from server, I'm getting different sorts of garbage, double-encoded text from what I guess.

How to POST text with correct charset? I suspect the answer to this is very simple and obvious to anyone with basic knowledge of web technologies, but not to me, alas.

5 min edit: the charset to use is actually "koi8-r"; that's what server expects, what's working with WWW:Mechanize, and what I'm trying (but no success) with Net::Async::HTTP in the 1st place.


In reply to 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":



  • 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.