Change 13740 by jhi@alpha on 2001/12/17 19:11:29
Demote the surrogate and non-character errors to warnings.
Affected files ...
.... //depot/perl/pod/perldiag.pod#251 edit
.... //depot/perl/t/lib/warnings/utf8#4 edit
.... //depot/perl/t/op/ord.t#12 edit
.... //depot/perl/utf8.c#132 edit
Differences ...
==== //depot/perl/pod/perldiag.pod#251 (text) ====
Index: perl/pod/perldiag.pod
--- perl/pod/perldiag.pod.~1~ Mon Dec 17 12:15:05 2001
+++ perl/pod/perldiag.pod Mon Dec 17 12:15:05 2001
@@ -3605,8 +3605,9 @@
=item Unicode character %s is illegal
-Certain Unicode characters have been designated off-limits by the
-Unicode standard and should not be generated.
+(W utf8) Certain Unicode characters have been designated off-limits by
+the Unicode standard and should not be generated. If you really know
+what you are doing you can turn off this warning by C<no warnings 'utf8';>.
=item Unknown BYTEORDER
@@ -4004,11 +4005,13 @@
=item UTF-16 surrogate %s
-(F) You tried to generate half of an UTF-16 surrogate by requesting
-a Unicode character between the code points 0xD800 and 0xDFFF (inclusive).
-That range is reserved exclusively for the use of UTF-16 encoding
-(by having two 16-bit UCS-2 characters); but Perl encodes its characters
-in UTF-8, so what you got is a very illegal character.
+(W utf8) You tried to generate half of an UTF-16 surrogate by
+requesting a Unicode character between the code points 0xD800 and
+0xDFFF (inclusive). That range is reserved exclusively for the use of
+UTF-16 encoding (by having two 16-bit UCS-2 characters); but Perl
+encodes its characters in UTF-8, so what you got is a very illegal
+character. If you really know what you are doing you can turn off
+this warning by C<no warnings 'utf8';>.
=item Value of %s can be "0"; test with defined()
==== //depot/perl/t/lib/warnings/utf8#4 (text) ====
Index: perl/t/lib/warnings/utf8
--- perl/t/lib/warnings/utf8.~1~ Mon Dec 17 12:15:05 2001
+++ perl/t/lib/warnings/utf8 Mon Dec 17 12:15:05 2001
@@ -33,3 +33,16 @@
Malformed UTF-8 character (unexpected non-continuation byte 0x73 after start byte
0xf8) at - line 9.
Malformed UTF-8 character (unexpected non-continuation byte 0x73 after start byte
0xf8) at - line 14.
########
+use warnings 'utf8';
+my $surr = chr(0xD800);
+my $fff3 = chr(0xFFFE);
+my $ffff = chr(0xFFFF);
+no warnings 'utf8';
+$surr = chr(0xD800);
+$fffe = chr(0xFFFE);
+$ffff = chr(0xFFFF);
+EXPECT
+UTF-16 surrogate 0xd800 at - line 2.
+Unicode character 0xfffe is illegal at - line 3.
+Unicode character 0xffff is illegal at - line 4.
+########
==== //depot/perl/t/op/ord.t#12 (xtext) ====
Index: perl/t/op/ord.t
--- perl/t/op/ord.t.~1~ Mon Dec 17 12:15:05 2001
+++ perl/t/op/ord.t Mon Dec 17 12:15:05 2001
@@ -2,11 +2,11 @@
BEGIN {
chdir 't' if -d 't';
- @INC = '.';
+ @INC = qw(.);
require "test.pl";
}
-print "1..8\n";
+plan tests => 7;
# compile time evaluation
@@ -33,10 +33,3 @@
$x = "\x{1234}";
is(ord($x), 0x1234, 'runtime ord \x{....}');
-{
- eval 'my $surrogate = chr(0xD800)';
-
- like($@, qr/^UTF-16 surrogate 0xd800 /, "surrogates bad");
-}
-
-
==== //depot/perl/utf8.c#132 (text) ====
Index: perl/utf8.c
--- perl/utf8.c.~1~ Mon Dec 17 12:15:05 2001
+++ perl/utf8.c Mon Dec 17 12:15:05 2001
@@ -46,11 +46,14 @@
U8 *
Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv)
{
- if (UNICODE_IS_SURROGATE(uv))
- Perl_croak(aTHX_ "UTF-16 surrogate 0x%04"UVxf, uv);
- else if ((uv >= 0xFDD0 && uv <= 0xFDEF) ||
- (uv == 0xFFFE || uv == 0xFFFF))
- Perl_croak(aTHX_ "Unicode character 0x%04"UVxf" is illegal", uv);
+ if (ckWARN_d(WARN_UTF8)) {
+ if (UNICODE_IS_SURROGATE(uv))
+ Perl_warner(aTHX_ WARN_UTF8, "UTF-16 surrogate 0x%04"UVxf, uv);
+ else if ((uv >= 0xFDD0 && uv <= 0xFDEF) ||
+ (uv == 0xFFFE || uv == 0xFFFF))
+ Perl_warner(aTHX_ WARN_UTF8,
+ "Unicode character 0x%04"UVxf" is illegal", uv);
+ }
if (UNI_IS_INVARIANT(uv)) {
*d++ = UTF_TO_NATIVE(uv);
return d;
End of Patch.