I'm a little out of my depth here, but have you tried:
$mech->add_header( Encoding => 'OFFICIAL_ENCODING_LABEL_FOR_YOUR_DATA' + );
That is, provide the string that would normally be used to identify the encoding of your "EUC encoded string" in the http and/or html header.

Apart from that, it appears (from looking at the source for WWW::Mechanize) that there's nothing in the module to alter the encoding of data being passed through it to a given web server. So if you're having trouble getting the strings to go through correctly, you may need to exercise more control in your own code to manage encoding issues.

For example, there are some WM methods that allow you to pass an optional file handle for output; if you don't supply one, it prints to STDOUT in the "normal" (default) manner. This should usually do the right thing, but if/when it doesn't, maybe you need to supply a file handle with the correct encoding layer already assigned via the 3-arg open call.

BTW, is it really the case that referring to your data as "EUC" is sufficient to identify what it really is? I've seen references to 'euc-jp' and 'euc-kr' and 'euc-cn', but not the simple "euc" by itself -- which makes me wonder if maybe "euc" by itself is ambiguous... (Maybe your reference to "Jcode" would peg it to Japanese, but I wouldn't know.)


In reply to Re: WWW::Mechanize encoding again... by graff
in thread WWW::Mechanize encoding again... by GaijinPunch

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.