I will try to rip some code to demonstrate the problem.

One important note: There is no problem on Windows ActivePerl. It only happens on Linux.

Here is how I handle input data:

################################### package main; ################################### sub decode_string { my $string = shift; Encode::_utf8_off($string); my $encoding = Encode::Guess->guess($string); if (!ref($encoding)) { $string = Encode::decode_utf8($string, 1); }else{ $string = $encoding->decode($string) if $encoding; } return $string; } CGI::param($_, map { decode_string($_) } (CGI::param($_)) ) foreach CG +I::param; ##################################### package My::DBI; ##################################### sub fixutfflag { my $self = shift; do { Encode::_utf8_on($_); } foreach @{$self}{$self->columns}; } ##################################### package My::DBI::Class; ##################################### __PACKAGE__->add_trigger( select => sub { my $self = shift; $self->fixutfflag; });

In reply to Re^2: UTF-8 problem, some chars appear as \x.. by zanzibar
in thread UTF-8 problem, some chars appear as \x.. by zanzibar

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.