summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/locale.t8
-rw-r--r--mg.c24
-rw-r--r--pod/perldelta.pod12
-rw-r--r--pod/perlvar.pod4
4 files changed, 25 insertions, 23 deletions
diff --git a/lib/locale.t b/lib/locale.t
index f0457353a7..38b0d09fb3 100644
--- a/lib/locale.t
+++ b/lib/locale.t
@@ -1783,8 +1783,8 @@ foreach my $Locale (@Locale) {
$ok13 = $w == 0;
# Look for non-ASCII error messages, and verify that the first
- # such is NOT in UTF-8 (the others almost certainly will be like
- # the first) See [perl #119499].
+ # such is in UTF-8 (the others almost certainly will be like the
+ # first).
$ok14 = 1;
$ok14_5 = 1;
foreach my $err (keys %!) {
@@ -1792,7 +1792,7 @@ foreach my $Locale (@Locale) {
$! = eval "&Errno::$err"; # Convert to strerror() output
my $strerror = "$!";
if ("$strerror" =~ /\P{ASCII}/) {
- $ok14 = ! utf8::is_utf8($strerror);
+ $ok14 = utf8::is_utf8($strerror);
no locale;
$ok14_5 = "$!" !~ /\P{ASCII}/;
last;
@@ -1876,7 +1876,7 @@ foreach my $Locale (@Locale) {
$problematical_tests{$locales_test_number} = 1;
report_result($Locale, ++$locales_test_number, $ok14);
- $test_names{$locales_test_number} = 'Verify that non-ASCII UTF-8 error messages are NOT in UTF-8';
+ $test_names{$locales_test_number} = 'Verify that non-ASCII UTF-8 error messages are in UTF-8';
report_result($Locale, ++$locales_test_number, $ok14_5);
$test_names{$locales_test_number} = '... and are ASCII outside "use locale"';
diff --git a/mg.c b/mg.c
index 80f5a7b004..e62e9e6c9b 100644
--- a/mg.c
+++ b/mg.c
@@ -753,24 +753,19 @@ S_fixup_errno_string(pTHX_ SV* sv)
if(strEQ(SvPVX(sv), "")) {
sv_catpv(sv, UNKNOWN_ERRNO_MSG);
}
-#if 0
- /* This is disabled to get v5.20 out the door. It means that $! behaves as
- * if in the scope of both 'use locale' and 'use bytes'. This can cause
- * mixed encodings and double utf8 upgrading, See towards the end of the
- * thread for [perl #119499] */
else {
/* In some locales the error string may come back as UTF-8, in which
* case we should turn on that flag. This didn't use to happen, and to
- * avoid any possible backward compatibility issues, we don't turn on
- * the flag unless we have to. So the flag stays off for an entirely
- * ASCII string. We assume that if the string looks like UTF-8, it
- * really is UTF-8: "text in any other encoding that uses bytes with
- * the high bit set is extremely unlikely to pass a UTF-8 validity
- * test" (http://en.wikipedia.org/wiki/Charset_detection). There is a
- * potential that we will get it wrong however, especially on short
- * error message text. (If it turns out to be necessary, we could also
- * keep track if the current LC_MESSAGES locale is UTF-8) */
+ * avoid as many possible backward compatibility issues as possible, we
+ * don't turn on the flag unless we have to. So the flag stays off for
+ * an entirely ASCII string. We assume that if the string looks like
+ * UTF-8, it really is UTF-8: "text in any other encoding that uses
+ * bytes with the high bit set is extremely unlikely to pass a UTF-8
+ * validity test" (http://en.wikipedia.org/wiki/Charset_detection).
+ * There is a potential that we will get it wrong however, especially
+ * on short error message text. (If it turns out to be necessary, we
+ * could also keep track if the current LC_MESSAGES locale is UTF-8) */
if (! IN_BYTES /* respect 'use bytes' */
&& ! is_ascii_string((U8*) SvPVX_const(sv), SvCUR(sv))
&& is_utf8_string((U8*) SvPVX_const(sv), SvCUR(sv)))
@@ -778,7 +773,6 @@ S_fixup_errno_string(pTHX_ SV* sv)
SvUTF8_on(sv);
}
}
-#endif
}
#ifdef VMS
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 5da82185fc..d4278b3c54 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -105,6 +105,18 @@ handle locale, this can cause garbage text to be displayed. It's better
to display text that is translatable via some tool than garbage text
which is much harder to figure out.
+=head2 C<"$!"> text will be returned in UTF-8 when appropriate
+
+The stringification of C<$!> and C<$^E> will have the UTF-8 flag set
+when the text is actually non-ASCII UTF-8. This will enable programs
+that are set up to be locale-aware to properly output messages in the
+user's native language. Code that needs to continue the 5.20 and
+earlier behavior can do the stringification within the scopes of both
+'use bytes' and 'use locale ":messages". No other Perl operations will
+be affected by locale; only C<$!> and C<$^E> stringification. The
+'bytes' pragma causes the UTF-8 flag to not be set, just as in previous
+Perl releases. This resolves [perl #112208].
+
=head1 Deprecations
XXX Any deprecated features, syntax, modules etc. should be listed here.
diff --git a/pod/perlvar.pod b/pod/perlvar.pod
index 4b6bb74cf5..cd917afa7e 100644
--- a/pod/perlvar.pod
+++ b/pod/perlvar.pod
@@ -1765,10 +1765,6 @@ It can be used immediately before invoking the C<die()> operator,
to set the exit value, or to inspect the system error string
corresponding to error I<n>, or to restore C<$!> to a meaningful state.
-Note that when stringified, the text is always returned as if both
-S<L<C<"use locale">|perllocale>> and S<L<C<"use bytes">|bytes>> are in
-effect. This is likely to change in v5.22.
-
Mnemonic: What just went bang?
=item %OS_ERROR