diff options
author | Karl Williamson <khw@cpan.org> | 2014-06-02 15:56:05 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-06-05 12:23:02 -0600 |
commit | 2c6ee1a7a1ce7cff7755f9aa43a65b8278dd82a1 (patch) | |
tree | 12f9cd50e04ff9cbc67d626248afad706da8ea17 /embed.h | |
parent | dc36ed0caa7afbcad35a51601fe96c91233391a5 (diff) | |
download | perl-2c6ee1a7a1ce7cff7755f9aa43a65b8278dd82a1.tar.gz |
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.
Diffstat (limited to 'embed.h')
-rw-r--r-- | embed.h | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -343,6 +343,7 @@ #define my_popen_list(a,b,c) Perl_my_popen_list(aTHX_ a,b,c) #define my_setenv(a,b) Perl_my_setenv(aTHX_ a,b) #define my_socketpair Perl_my_socketpair +#define my_strerror(a) Perl_my_strerror(aTHX_ a) #define my_strftime(a,b,c,d,e,f,g,h,i,j) Perl_my_strftime(aTHX_ a,b,c,d,e,f,g,h,i,j) #define newANONATTRSUB(a,b,c,d) Perl_newANONATTRSUB(aTHX_ a,b,c,d) #define newANONHASH(a) Perl_newANONHASH(aTHX_ a) |