Molo::Exception generate warnings while read non-utf8 file

320 views
Skip to first unread message

a][eman

unread,
Oct 14, 2011, 7:29:05 PM10/14/11
to Mojolicious
Hi!

I have some problem with Mojo::Exception. It generates a lot of trash
on stderr, like this

utf8 "\xE2" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN256> line 9
utf8 "\xEB" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 53.
utf8 "\xCE" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 65.
utf8 "\xE4" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 110.
utf8 "\xE5" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 139.

I think, It happens because Mojo::Exception opens file with
flag :utf8, but my files have non-utf8 encoding:

4 84 #
Slurp
4 85 my $handle = IO::File->new($file,
'<:utf8');
4 86 my @lines = <$handle>;

Notice that there is same thing in line 45 w/o :utf8 flag worked well
for me:

4 45 next unless my $handle = IO::File->new("<
$f");
4 46 my @lines = <
$handle>;
4 47 push @{$frames[-1]}, $lines[$l - 1];

May be :utf8 does not required in line 85 ? If this is required, how
can I workaround my problem without disabling Mojo::Exceptions?

It`s real problem for me, because leads to failure on frontend server
(Nginx) with error which sounds like "too big headers while reading
responce from upstream" and as result 502 G/W Timeout on client.

Thanks!

Sebastian Riedel

unread,
Oct 15, 2011, 1:46:49 AM10/15/11
to mojol...@googlegroups.com
I have some problem with Mojo::Exception. It generates a lot of trash
on stderr, like this

utf8 "\xE2" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN256> line 9
utf8 "\xEB" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 53.
utf8 "\xCE" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 65.
utf8 "\xE4" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 110.
utf8 "\xE5" does not map to Unicode at /usr/local/share/perl/5.10.0/
Mojo/Exception.pm line 86, <GEN212> line 139.

I think, It happens because Mojo::Exception opens file with
flag :utf8, but my files have non-utf8 encoding:

My personal opinion is that utf8 and ascii are the only valid encodings for perl source code, and i don't see a good reason to use anything else.
If there's a simple solution for supporting all encodings i'm all ears, but otherwise i'm ok with expecting utf8.

-- 
Sebastian Riedel

Bernhard Graf

unread,
Oct 15, 2011, 5:36:18 AM10/15/11
to mojol...@googlegroups.com
Am 15.10.2011 07:46 schrieb Sebastian Riedel:

> My personal opinion is that utf8 and ascii are the only valid encodings
> for perl source code, and i don't see a good reason to use anything else.

agreed.

> If there's a simple solution for supporting all encodings i'm all ears,
> but otherwise i'm ok with expecting utf8.

Without looking at the respective code, the question is:
Is there a reason for decoding the incoming data at all?

If the code just does "decode incoming", then "encode outgoing", without
doing any string manipulation in between like sorting or length
checking, then it is better to save the (de|en)coding and take the data
as a byte stream.

The worst thing, that can happen is, that a browser might show strange
characters if the header's Content-Type encoding does not match the
actual encoding of the data that was send to the browser.

Bernhard

Sebastian Riedel

unread,
Oct 15, 2011, 5:42:35 AM10/15/11
to mojol...@googlegroups.com
Without looking at the respective code, the question is:
Is there a reason for decoding the incoming data at all?
Please do take a look at the respective code, templates depend on data being characters, not bytes.
Reply all
Reply to author
Forward
0 new messages