Mojo::Log already encodes data by default. Anything you send to stderr
outside of that should be encoded if necessary.

-Dan

On Wed, Oct 10, 2018 at 11:53 AM Alex Povolotsky <tark...@gmail.com> wrote:

> So I should not binmode STDERR, ':utf8' if I'm using Mojo::Log and always
> explicitly encode() data?
>
> суббота, 6 октября 2018 г., 20:30:12 UTC+3 пользователь Dan Book написал:
>>
>> The script is not quite correct. I suspect if you add "use warnings" you
>> will see a "Wide character in print" warning, because you are not encoding
>> your unicode characters to UTF-8 before printing them. However, on the
>> server where you are seeing the double encoding, perhaps you have a
>> PERL5OPT environment variable which is setting something like "-CSAD" and
>> thus encoding all output handles by default (this should not be globally
>> set, because it can mess with modules that don't expect it like this).
>>
>> -Dan
>>
>> On Sat, Oct 6, 2018 at 10:15 AM Alex Povolotsky <tar...@gmail.com> wrote:
>>
>>> Quite interesting. The simple script
>>>
>>> === cut mojolog ===
>>>
>>> #!/usr/bin/env perl
>>> use strict;
>>> use utf8;
>>> use Mojo::Log;
>>> my $log = new Mojo::Log;
>>> print "Просто принт\n";
>>> $log->info('тест лога');
>>> === cut mojolog ===
>>>
>>> yields fine results on all my servers but one.
>>>
>>> On it, I'm getting
>>>
>>> % perl mojolog
>>> Просто принт
>>> [Sat Oct  6 15:22:43 2018] [info] �е�� лога
>>>
>>> The second line is clearly wrong and seems to be badly encoded. Same
>>> version of OS, Perl, Mojolicious, same set of environment variables. What
>>> else could influence unicode processing?
>>>
>>> суббота, 6 октября 2018 г., 13:35:48 UTC+3 пользователь Alex Povolotsky
>>> написал:
>>>>
>>>> Hello
>>>>
>>>> How do I send UTF-8 constants to Mojo::Log? It forcefully encodes
>>>> everything so UTF-8 goes with double encoding and unreadable. Trying to
>>>> decode UTF-8 cat
>>>>
>>>> $log->info(decode('UTF-8', 'тест лога'));
>>>>
>>>> results in
>>>>
>>>> Use of uninitialized value $_[0] in join or string at
>>>> /usr/local/lib/perl5/site_perl/Mojo/Log.pm line 55.
>>>>
>>>> Looks like something is wrong...
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Mojolicious" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to mojolicious...@googlegroups.com.
>>> To post to this group, send email to mojol...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/mojolicious.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Mojolicious" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mojolicious+unsubscr...@googlegroups.com.
> To post to this group, send email to mojolicious@googlegroups.com.
> Visit this group at https://groups.google.com/group/mojolicious.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to mojolicious+unsubscr...@googlegroups.com.
To post to this group, send email to mojolicious@googlegroups.com.
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.

Reply via email to