This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use C locale for "$!" ouside 'use locale' scope
authorKarl Williamson <khw@cpan.org>
Mon, 2 Jun 2014 21:56:05 +0000 (15:56 -0600)
committerKarl Williamson <khw@cpan.org>
Thu, 5 Jun 2014 18:23:02 +0000 (12:23 -0600)
commit2c6ee1a7a1ce7cff7755f9aa43a65b8278dd82a1
tree12f9cd50e04ff9cbc67d626248afad706da8ea17
parentdc36ed0caa7afbcad35a51601fe96c91233391a5
Use C locale for "$!" ouside 'use locale' scope

The stringification of $! has long been an outlier in Perl locale
handling.  The theory has been that these operating system messages are
likely to be of use to the final user, and should be in their language.
Things like
    No space left on device
    Can't fork
are not something the program is likely to handle, but could be
meaningfully helpful to the end-user.

There are problems with this though.  One is that many perl messages are
in English, with the $! appended to them, so that the resultant message
is of mixed language, and may need to be translated anyway.  Things like
    No space left on device
probably won't need the remaining portion of the message to give someone
a clear indication as to what's wrong.  But there are many other
messages where both the OS error and the Perl error would be needed
togther to understand the problem.  An on-line translation tool can be
used to do this.

Another problem is that it can lead to garbage coming out on the user's
terminal when the program is not expecting UTF-8, but the underlying
locale is UTF-8.  This is what happens in Bug #112208, and another that
was merged with it.  It's a lot harder to translate mojibake via an
online tool than English.

This commit solves that by using the C locale for messages, except
within the scope of 'use locale'.  It is extremely likely that the
messages in the C locale will be English, but if not they will be ASCII,
and there will be no garbage printed.  A program that says "use locale"
is indicating that it has the intelligence necessary to deal with
locales.
embed.fnc
embed.h
lib/locale.t
locale.c
mg.c
pod/perldelta.pod
pod/perllocale.pod
proto.h
util.c