na has asked for the wisdom of the Perl Monks concerning the following question:
I have a code like this
Because "$!" is just a byte string, output is terrible. My questions are:#!/usr/bin/perl use warnings; use strict; use utf8; binmode( STDERR, ':utf8' ); $ENV{ LANG } = 'C'; warn "<UTF-8 string>"; open( my $in, '<', 'non-existing-file' ) || die $!;
1) Are there any way to enfoce '$!' to 'C' locale. "$ENV{ LANG } = 'C';" does,'t works.
2) Are there any good solution? Some my poor workarounds are:
- Don't use 'use utf8'
- on't use "binmode( STDERR, ':utf8' );" and live with "Wide character in warn" messages.
- Decode '$!'. and don't use any modules which uses 'die $!'
- use __DIE__/__WARN__ signal-handlers.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to handle encoding for STDERR
by andal (Hermit) on Feb 11, 2013 at 08:01 UTC | |
by na (Novice) on Feb 12, 2013 at 13:52 UTC | |
Re: How to handle encoding for STDERR
by Anonymous Monk on Feb 11, 2013 at 05:05 UTC | |
by Anonymous Monk on Feb 11, 2013 at 05:10 UTC | |
by na (Novice) on Feb 12, 2013 at 13:08 UTC | |
by Anonymous Monk on Feb 12, 2013 at 13:21 UTC | |
Re: How to handle encoding for STDERR
by ww (Archbishop) on Feb 11, 2013 at 13:51 UTC | |
Re: How to handle encoding for STDERR
by Anonymous Monk on Feb 11, 2013 at 13:07 UTC |
Back to
Seekers of Perl Wisdom