This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perlapi: Fix grammar
[perl5.git] / t / lib / warnings / utf8
CommitLineData
f0df466a
JH
1
2 utf8.c AOK
3
4b88fb76 4 [utf8_to_uvchr_buf]
f0df466a
JH
5 Malformed UTF-8 character
6 my $a = ord "\x80" ;
7
8 Malformed UTF-8 character
9 my $a = ord "\xf080" ;
10 <<<<<< this warning can't be easily triggered from perl anymore
11
12 [utf16_to_utf8]
13 Malformed UTF-16 surrogate
93f09d7b 14 <<<<<< Add a test when something actually calls utf16_to_utf8
f0df466a
JH
15
16__END__
4b88fb76 17# utf8.c [utf8_to_uvchr_buf] -W
6cdc5cd8 18# NAME Malformed under 'use utf8' in double-quoted string
f0df466a
JH
19BEGIN {
20 if (ord('A') == 193) {
72b4e0d1 21 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
f0df466a
JH
22 exit 0;
23 }
24}
25use utf8 ;
6cdc5cd8 26no warnings; # Malformed is a fatal error, so gets output anyway.
f0df466a 27my $a = "snøstorm" ;
6cdc5cd8
KW
28EXPECT
29Malformed UTF-8 character: \xf8\x73\x74\x6f\x72 (unexpected non-continuation byte 0x73, immediately after start byte 0xf8; need 5 bytes, got 1) at - line 10.
30Malformed UTF-8 character (fatal) at - line 10.
31########
32# NAME Malformed under 'use utf8' in single-quoted string
33BEGIN {
34 if (ord('A') == 193) {
35 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
36 exit 0;
37 }
f0df466a 38}
6cdc5cd8
KW
39use utf8 ;
40no warnings; # Malformed is a fatal error, so gets output anyway.
41my $a = 'snøstorm' ;
f0df466a 42EXPECT
7cf8d05d 43Malformed UTF-8 character: \xf8\x73\x74\x6f\x72 (unexpected non-continuation byte 0x73, immediately after start byte 0xf8; need 5 bytes, got 1) at - line 9.
6cdc5cd8 44Malformed UTF-8 character (fatal) at - line 9.
f0df466a 45########
507b9800 46use warnings 'utf8';
9ae3ac1a
KW
47my $d7ff = uc(chr(0xD7FF));
48my $d800 = uc(chr(0xD800));
49my $dfff = uc(chr(0xDFFF));
50my $e000 = uc(chr(0xE000));
51my $feff = uc(chr(0xFEFF));
52my $fffd = uc(chr(0xFFFD));
53my $fffe = uc(chr(0xFFFE));
54my $ffff = uc(chr(0xFFFF));
55my $hex4 = uc(chr(0x10000));
56my $hex5 = uc(chr(0x100000));
57my $maxm1 = uc(chr(0x10FFFE));
58my $max = uc(chr(0x10FFFF));
59my $nonUnicode = uc(chr(0x110000));
507b9800 60no warnings 'utf8';
9ae3ac1a
KW
61my $d7ff = uc(chr(0xD7FF));
62my $d800 = uc(chr(0xD800));
63my $dfff = uc(chr(0xDFFF));
64my $e000 = uc(chr(0xE000));
65my $feff = uc(chr(0xFEFF));
66my $fffd = uc(chr(0xFFFD));
67my $fffe = uc(chr(0xFFFE));
68my $ffff = uc(chr(0xFFFF));
69my $hex4 = uc(chr(0x10000));
70my $hex5 = uc(chr(0x100000));
71my $maxm1 = uc(chr(0x10FFFE));
72my $max = uc(chr(0x10FFFF));
73my $nonUnicode = uc(chr(0x110000));
507b9800 74EXPECT
9ae3ac1a
KW
75Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
76Operation "uc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
77Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 14.
507b9800 78########
62961d2e 79use warnings 'utf8';
8457b38f
KW
80my $d800 = uc(chr(0xD800));
81my $nonUnicode = uc(chr(0x110000));
82no warnings 'surrogate';
83my $d800 = uc(chr(0xD800));
84my $nonUnicode = uc(chr(0x110000));
85EXPECT
86Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 2.
87Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 3.
88Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 6.
89########
90use warnings 'utf8';
91my $d800 = uc(chr(0xD800));
92my $nonUnicode = uc(chr(0x110000));
8457b38f
KW
93no warnings 'non_unicode';
94my $d800 = uc(chr(0xD800));
95my $nonUnicode = uc(chr(0x110000));
8457b38f
KW
96EXPECT
97Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 2.
98Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 3.
9415f659
KW
99Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 5.
100########
9415f659 101use warnings 'utf8';
760c7c2f 102no warnings 'deprecated'; # This is above IV_MAX on 32 bit machines
9415f659
KW
103my $big_nonUnicode = uc(chr(0x8000_0000));
104no warnings 'non_unicode';
105my $big_nonUnicode = uc(chr(0x8000_0000));
106EXPECT
760c7c2f 107Operation "uc" returns its argument for non-Unicode code point 0x80000000 at - line 3.
8457b38f
KW
108########
109use warnings 'utf8';
9ae3ac1a
KW
110my $d7ff = lc pack("U", 0xD7FF);
111my $d800 = lc pack("U", 0xD800);
112my $dfff = lc pack("U", 0xDFFF);
113my $e000 = lc pack("U", 0xE000);
114my $feff = lc pack("U", 0xFEFF);
115my $fffd = lc pack("U", 0xFFFD);
116my $fffe = lc pack("U", 0xFFFE);
117my $ffff = lc pack("U", 0xFFFF);
118my $hex4 = lc pack("U", 0x10000);
119my $hex5 = lc pack("U", 0x100000);
120my $maxm1 = lc pack("U", 0x10FFFE);
121my $max = lc pack("U", 0x10FFFF);
122my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 123no warnings 'utf8';
9ae3ac1a
KW
124my $d7ff = lc pack("U", 0xD7FF);
125my $d800 = lc pack("U", 0xD800);
126my $dfff = lc pack("U", 0xDFFF);
127my $e000 = lc pack("U", 0xE000);
128my $feff = lc pack("U", 0xFEFF);
129my $fffd = lc pack("U", 0xFFFD);
130my $fffe = lc pack("U", 0xFFFE);
131my $ffff = lc pack("U", 0xFFFF);
132my $hex4 = lc pack("U", 0x10000);
133my $hex5 = lc pack("U", 0x100000);
134my $maxm1 = lc pack("U", 0x10FFFE);
135my $max = lc pack("U", 0x10FFFF);
136my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 137EXPECT
9ae3ac1a
KW
138Operation "lc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
139Operation "lc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
140Operation "lc" returns its argument for non-Unicode code point 0x110000 at - line 14.
62961d2e
JH
141########
142use warnings 'utf8';
9ae3ac1a
KW
143my $d7ff = ucfirst "\x{D7FF}";
144my $d800 = ucfirst "\x{D800}";
145my $dfff = ucfirst "\x{DFFF}";
146my $e000 = ucfirst "\x{E000}";
147my $feff = ucfirst "\x{FEFF}";
148my $fffd = ucfirst "\x{FFFD}";
149my $fffe = ucfirst "\x{FFFE}";
150my $ffff = ucfirst "\x{FFFF}";
151my $hex4 = ucfirst "\x{10000}";
152my $hex5 = ucfirst "\x{100000}";
153my $maxm1 = ucfirst "\x{10FFFE}";
154my $max = ucfirst "\x{10FFFF}";
155my $nonUnicode = ucfirst "\x{110000}";
62961d2e 156no warnings 'utf8';
9ae3ac1a
KW
157my $d7ff = ucfirst "\x{D7FF}";
158my $d800 = ucfirst "\x{D800}";
159my $dfff = ucfirst "\x{DFFF}";
160my $e000 = ucfirst "\x{E000}";
161my $feff = ucfirst "\x{FEFF}";
162my $fffd = ucfirst "\x{FFFD}";
163my $fffe = ucfirst "\x{FFFE}";
164my $ffff = ucfirst "\x{FFFF}";
165my $hex4 = ucfirst "\x{10000}";
166my $hex5 = ucfirst "\x{100000}";
167my $maxm1 = ucfirst "\x{10FFFE}";
168my $max = ucfirst "\x{10FFFF}";
169my $nonUnicode = ucfirst "\x{110000}";
170EXPECT
171Operation "ucfirst" returns its argument for UTF-16 surrogate U+D800 at - line 3.
172Operation "ucfirst" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
173Operation "ucfirst" returns its argument for non-Unicode code point 0x110000 at - line 14.
174########
2d88a86a 175# NAME Matching \p{} against above-Unicode
9ae3ac1a
KW
176use warnings 'utf8';
177chr(0xD7FF) =~ /\p{Any}/;
178chr(0xD800) =~ /\p{Any}/;
179chr(0xDFFF) =~ /\p{Any}/;
180chr(0xE000) =~ /\p{Any}/;
181chr(0xFEFF) =~ /\p{Any}/;
182chr(0xFFFD) =~ /\p{Any}/;
183chr(0xFFFE) =~ /\p{Any}/;
184chr(0xFFFF) =~ /\p{Any}/;
185chr(0x10000) =~ /\p{Any}/;
186chr(0x100000) =~ /\p{Any}/;
187chr(0x10FFFE) =~ /\p{Any}/;
188chr(0x10FFFF) =~ /\p{Any}/;
2d88a86a
KW
189chr(0x110000) =~ /[\p{Any}]/;
190chr(0x110001) =~ /[\w\p{Any}]/;
191chr(0x10FFFF) =~ /\p{All}/;
192chr(0x110002) =~ /[\w\p{All}]/;
193chr(0x110003) =~ /[\p{XPosixWord}]/;
194chr(0x110004) =~ /[\P{XPosixWord}]/;
195chr(0x110005) =~ /^[\p{Unassigned}]/;
196chr(0x110006) =~ /^[\P{Unassigned}]/;
197# Only Unicode properties give non-Unicode warnings, and only those properties
198# which do match above Unicode; and not when something else in the class
199# matches above Unicode. Below we test three ways where something outside the
200# property may match non-Unicode: a code point above it, a class \S that we
201# know at compile time doesn't, and a class \W whose values aren't (at the time
202# of this writing) specified at compile time, but which wouldn't match
5073ffbd
KW
203chr(0x110050) =~ /\w/;
204chr(0x110051) =~ /\W/;
205chr(0x110052) =~ /\d/;
206chr(0x110053) =~ /\D/;
207chr(0x110054) =~ /\s/;
208chr(0x110055) =~ /\S/;
209chr(0x110056) =~ /[[:word:]]/;
210chr(0x110057) =~ /[[:^word:]]/;
211chr(0x110058) =~ /[[:alnum:]]/;
212chr(0x110059) =~ /[[:^alnum:]]/;
213chr(0x11005A) =~ /[[:space:]]/;
214chr(0x11005B) =~ /[[:^space:]]/;
215chr(0x11005C) =~ /[[:digit:]]/;
216chr(0x11005D) =~ /[[:^digit:]]/;
217chr(0x11005E) =~ /[[:alpha:]]/;
218chr(0x11005F) =~ /[[:^alpha:]]/;
219chr(0x110060) =~ /[[:ascii:]]/;
220chr(0x110061) =~ /[[:^ascii:]]/;
221chr(0x110062) =~ /[[:cntrl:]]/;
222chr(0x110063) =~ /[[:^cntrl:]]/;
223chr(0x110064) =~ /[[:graph:]]/;
224chr(0x110065) =~ /[[:^graph:]]/;
225chr(0x110066) =~ /[[:lower:]]/;
226chr(0x110067) =~ /[[:^lower:]]/;
227chr(0x110068) =~ /[[:print:]]/;
228chr(0x110069) =~ /[[:^print:]]/;
229chr(0x11006A) =~ /[[:punct:]]/;
230chr(0x11006B) =~ /[[:^punct:]]/;
231chr(0x11006C) =~ /[[:upper:]]/;
232chr(0x11006D) =~ /[[:^upper:]]/;
233chr(0x11006E) =~ /[[:xdigit:]]/;
234chr(0x11006F) =~ /[[:^xdigit:]]/;
235chr(0x110070) =~ /[[:blank:]]/;
236chr(0x110071) =~ /[[:^blank:]]/;
2d88a86a
KW
237chr(0x111010) =~ /[\W\p{Unassigned}]/;
238chr(0x111011) =~ /[\W\P{Unassigned}]/;
239chr(0x112010) =~ /[\S\p{Unassigned}]/;
240chr(0x112011) =~ /[\S\P{Unassigned}]/;
241chr(0x113010) =~ /[\x{110000}\p{Unassigned}]/;
242chr(0x113011) =~ /[\x{110000}\P{Unassigned}]/;
9ae3ac1a
KW
243no warnings 'utf8';
244chr(0xD7FF) =~ /\p{Any}/;
245chr(0xD800) =~ /\p{Any}/;
246chr(0xDFFF) =~ /\p{Any}/;
247chr(0xE000) =~ /\p{Any}/;
248chr(0xFEFF) =~ /\p{Any}/;
249chr(0xFFFD) =~ /\p{Any}/;
250chr(0xFFFE) =~ /\p{Any}/;
251chr(0xFFFF) =~ /\p{Any}/;
252chr(0x10000) =~ /\p{Any}/;
253chr(0x100000) =~ /\p{Any}/;
254chr(0x10FFFE) =~ /\p{Any}/;
255chr(0x10FFFF) =~ /\p{Any}/;
2d88a86a
KW
256chr(0x110000) =~ /[\p{Any}]/;
257chr(0x110001) =~ /[\w\p{Any}]/;
258chr(0x10FFFF) =~ /\p{All}/;
259chr(0x110002) =~ /[\w\p{All}]/;
260chr(0x110003) =~ /[\p{XPosixWord}]/;
261chr(0x110004) =~ /[\P{XPosixWord}]/;
262chr(0x110005) =~ /^[\p{Unassigned}]/;
263chr(0x110006) =~ /^[\P{Unassigned}]/;
5073ffbd
KW
264chr(0x110050) =~ /\w/;
265chr(0x110051) =~ /\W/;
266chr(0x110052) =~ /\d/;
267chr(0x110053) =~ /\D/;
268chr(0x110054) =~ /\s/;
269chr(0x110055) =~ /\S/;
270chr(0x110056) =~ /[[:word:]]/;
271chr(0x110057) =~ /[[:^word:]]/;
272chr(0x110058) =~ /[[:alnum:]]/;
273chr(0x110059) =~ /[[:^alnum:]]/;
274chr(0x11005A) =~ /[[:space:]]/;
275chr(0x11005B) =~ /[[:^space:]]/;
276chr(0x11005C) =~ /[[:digit:]]/;
277chr(0x11005D) =~ /[[:^digit:]]/;
278chr(0x11005E) =~ /[[:alpha:]]/;
279chr(0x11005F) =~ /[[:^alpha:]]/;
280chr(0x110060) =~ /[[:ascii:]]/;
281chr(0x110061) =~ /[[:^ascii:]]/;
282chr(0x110062) =~ /[[:cntrl:]]/;
283chr(0x110063) =~ /[[:^cntrl:]]/;
284chr(0x110064) =~ /[[:graph:]]/;
285chr(0x110065) =~ /[[:^graph:]]/;
286chr(0x110066) =~ /[[:lower:]]/;
287chr(0x110067) =~ /[[:^lower:]]/;
288chr(0x110068) =~ /[[:print:]]/;
289chr(0x110069) =~ /[[:^print:]]/;
290chr(0x11006A) =~ /[[:punct:]]/;
291chr(0x11006B) =~ /[[:^punct:]]/;
292chr(0x11006C) =~ /[[:upper:]]/;
293chr(0x11006D) =~ /[[:^upper:]]/;
294chr(0x11006E) =~ /[[:xdigit:]]/;
295chr(0x11006F) =~ /[[:^xdigit:]]/;
296chr(0x110070) =~ /[[:blank:]]/;
297chr(0x110071) =~ /[[:^blank:]]/;
2d88a86a
KW
298chr(0x111010) =~ /[\W\p{Unassigned}]/;
299chr(0x111011) =~ /[\W\P{Unassigned}]/;
300chr(0x112010) =~ /[\S\p{Unassigned}]/;
301chr(0x112011) =~ /[\S\P{Unassigned}]/;
302chr(0x113010) =~ /[\x{110000}\p{Unassigned}]/;
303chr(0x113011) =~ /[\x{110000}\P{Unassigned}]/;
9ae3ac1a 304EXPECT
2d88a86a
KW
305Matched non-Unicode code point 0x110005 against Unicode property; may not be portable at - line 20.
306Matched non-Unicode code point 0x110006 against Unicode property; may not be portable at - line 21.
9ae3ac1a 307########
e9b08962 308# NAME Matching Unicode property against above-Unicode code point outputs a warning even if optimizer rejects the match (in synthetic start class)
2d88a86a
KW
309# Now have to make FATAL to guarantee being output
310use warnings FATAL => 'non_unicode';
ae986089
KW
311"\x{110000}" =~ /b?\p{Space}/;
312EXPECT
2d88a86a 313Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 3.
ae986089
KW
314########
315# NAME Matching POSIX class property against above-Unicode code point doesn't output a warning
316use warnings 'non_unicode';
2d88a86a 317use warnings FATAL => 'non_unicode';
ae986089
KW
318"\x{110000}" =~ /b?[[:space:]]/;
319EXPECT
320########
8457b38f
KW
321use warnings 'utf8';
322chr(0x110000) =~ /\p{Any}/;
2d88a86a
KW
323########
324# NAME utf8, non_unicode warnings categories work on Matched non-Unicode code point warning
325use warnings qw(utf8 non_unicode);
326chr(0x110000) =~ /^\p{Unassigned}/;
8457b38f 327no warnings 'non_unicode';
2d88a86a
KW
328chr(0x110001) =~ /\p{Unassigned}/;
329use warnings 'non_unicode';
330no warnings 'utf8';
331chr(0x110002) =~ /\p{Unassigned}/;
8457b38f 332EXPECT
2d88a86a 333Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 2.
8457b38f 334########
f2c2a6ab 335# NAME optimizable regnode should still give non_unicode warnings when fatalized
5073ffbd 336use warnings 'utf8';
f2c2a6ab 337use warnings FATAL => 'non_unicode';
845e7aa3 338chr(0x110000) =~ /\p{lb=cr}/;
f2c2a6ab 339EXPECT
2d88a86a 340Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 3.
f2c2a6ab
KW
341########
342# NAME optimizable regnode should not give non_unicode warnings when warnings are off
5073ffbd 343no warnings 'non_unicode';
845e7aa3 344chr(0x110000) =~ /\p{lb=cr}/;
5073ffbd 345EXPECT
5073ffbd 346########
2d88a86a
KW
347# NAME 'All' matches above-Unicode without any warning
348use warnings qw(utf8 non_unicode);
349chr(0x110000) =~ /\p{All}/;
350EXPECT
351########
9ae3ac1a
KW
352require "../test.pl";
353use warnings 'utf8';
a410ec23 354sub Is_Super { return '!utf8::Any' }
88d45d28
KW
355# The extra char is to avoid an optimization that avoids the problem when the
356# property is the only non-latin1 char in a class
357print "\x{1100000}" =~ /^[\p{Is_Super}\x{100}]$/, "\n";
a410ec23
KW
358EXPECT
3591
360########
361require "../test.pl";
362use warnings 'utf8';
9ae3ac1a
KW
363my $file = tempfile();
364open(my $fh, "+>:utf8", $file);
365print $fh "\x{D7FF}", "\n";
366print $fh "\x{D800}", "\n";
c87792c3
KW
367print $fh "\x{D900}", "\n";
368print $fh "\x{DA00}", "\n";
369print $fh "\x{DB00}", "\n";
370print $fh "\x{DC00}", "\n";
371print $fh "\x{DD00}", "\n";
372print $fh "\x{DE00}", "\n";
373print $fh "\x{DF00}", "\n";
9ae3ac1a
KW
374print $fh "\x{DFFF}", "\n";
375print $fh "\x{E000}", "\n";
376print $fh "\x{FDCF}", "\n";
377print $fh "\x{FDD0}", "\n";
c87792c3 378print $fh "\x{FDD1}", "\n";
9ae3ac1a
KW
379print $fh "\x{FDEF}", "\n";
380print $fh "\x{FDF0}", "\n";
c87792c3
KW
381print $fh "\x{FDFE}", "\n";
382print $fh "\x{FDFF}", "\n";
383print $fh "\x{FE00}", "\n";
9ae3ac1a
KW
384print $fh "\x{FEFF}", "\n";
385print $fh "\x{FFFD}", "\n";
386print $fh "\x{FFFE}", "\n";
387print $fh "\x{FFFF}", "\n";
388print $fh "\x{10000}", "\n";
c87792c3 389print $fh "\x{1FFFD}", "\n";
9ae3ac1a
KW
390print $fh "\x{1FFFE}", "\n";
391print $fh "\x{1FFFF}", "\n";
c87792c3
KW
392print $fh "\x{20000}", "\n";
393print $fh "\x{2FFFD}", "\n";
9ae3ac1a
KW
394print $fh "\x{2FFFE}", "\n";
395print $fh "\x{2FFFF}", "\n";
c87792c3
KW
396print $fh "\x{30000}", "\n";
397print $fh "\x{3FFFD}", "\n";
9ae3ac1a
KW
398print $fh "\x{3FFFE}", "\n";
399print $fh "\x{3FFFF}", "\n";
c87792c3
KW
400print $fh "\x{40000}", "\n";
401print $fh "\x{4FFFD}", "\n";
9ae3ac1a
KW
402print $fh "\x{4FFFE}", "\n";
403print $fh "\x{4FFFF}", "\n";
c87792c3
KW
404print $fh "\x{50000}", "\n";
405print $fh "\x{5FFFD}", "\n";
9ae3ac1a
KW
406print $fh "\x{5FFFE}", "\n";
407print $fh "\x{5FFFF}", "\n";
c87792c3
KW
408print $fh "\x{60000}", "\n";
409print $fh "\x{6FFFD}", "\n";
9ae3ac1a
KW
410print $fh "\x{6FFFE}", "\n";
411print $fh "\x{6FFFF}", "\n";
c87792c3
KW
412print $fh "\x{70000}", "\n";
413print $fh "\x{7FFFD}", "\n";
9ae3ac1a
KW
414print $fh "\x{7FFFE}", "\n";
415print $fh "\x{7FFFF}", "\n";
c87792c3
KW
416print $fh "\x{80000}", "\n";
417print $fh "\x{8FFFD}", "\n";
9ae3ac1a
KW
418print $fh "\x{8FFFE}", "\n";
419print $fh "\x{8FFFF}", "\n";
c87792c3
KW
420print $fh "\x{90000}", "\n";
421print $fh "\x{9FFFD}", "\n";
9ae3ac1a
KW
422print $fh "\x{9FFFE}", "\n";
423print $fh "\x{9FFFF}", "\n";
c87792c3
KW
424print $fh "\x{A0000}", "\n";
425print $fh "\x{AFFFD}", "\n";
9ae3ac1a
KW
426print $fh "\x{AFFFE}", "\n";
427print $fh "\x{AFFFF}", "\n";
c87792c3
KW
428print $fh "\x{B0000}", "\n";
429print $fh "\x{BFFFD}", "\n";
9ae3ac1a
KW
430print $fh "\x{BFFFE}", "\n";
431print $fh "\x{BFFFF}", "\n";
c87792c3
KW
432print $fh "\x{C0000}", "\n";
433print $fh "\x{CFFFD}", "\n";
9ae3ac1a
KW
434print $fh "\x{CFFFE}", "\n";
435print $fh "\x{CFFFF}", "\n";
c87792c3
KW
436print $fh "\x{D0000}", "\n";
437print $fh "\x{DFFFD}", "\n";
9ae3ac1a
KW
438print $fh "\x{DFFFE}", "\n";
439print $fh "\x{DFFFF}", "\n";
c87792c3
KW
440print $fh "\x{E0000}", "\n";
441print $fh "\x{EFFFD}", "\n";
9ae3ac1a
KW
442print $fh "\x{EFFFE}", "\n";
443print $fh "\x{EFFFF}", "\n";
c87792c3
KW
444print $fh "\x{F0000}", "\n";
445print $fh "\x{FFFFD}", "\n";
9ae3ac1a
KW
446print $fh "\x{FFFFE}", "\n";
447print $fh "\x{FFFFF}", "\n";
448print $fh "\x{100000}", "\n";
c87792c3 449print $fh "\x{10FFFD}", "\n";
9ae3ac1a
KW
450print $fh "\x{10FFFE}", "\n";
451print $fh "\x{10FFFF}", "\n";
452print $fh "\x{110000}", "\n";
c87792c3
KW
453print $fh "\x{11FFFD}", "\n";
454print $fh "\x{11FFFE}", "\n";
455print $fh "\x{11FFFF}", "\n";
456print $fh "\x{120000}", "\n";
9ae3ac1a
KW
457close $fh;
458EXPECT
459Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
c87792c3
KW
460Unicode surrogate U+D900 is illegal in UTF-8 at - line 7.
461Unicode surrogate U+DA00 is illegal in UTF-8 at - line 8.
462Unicode surrogate U+DB00 is illegal in UTF-8 at - line 9.
463Unicode surrogate U+DC00 is illegal in UTF-8 at - line 10.
464Unicode surrogate U+DD00 is illegal in UTF-8 at - line 11.
465Unicode surrogate U+DE00 is illegal in UTF-8 at - line 12.
466Unicode surrogate U+DF00 is illegal in UTF-8 at - line 13.
467Unicode surrogate U+DFFF is illegal in UTF-8 at - line 14.
468Unicode non-character U+FDD0 is not recommended for open interchange in print at - line 17.
469Unicode non-character U+FDD1 is not recommended for open interchange in print at - line 18.
470Unicode non-character U+FDEF is not recommended for open interchange in print at - line 19.
471Unicode non-character U+FFFE is not recommended for open interchange in print at - line 26.
472Unicode non-character U+FFFF is not recommended for open interchange in print at - line 27.
473Unicode non-character U+1FFFE is not recommended for open interchange in print at - line 30.
474Unicode non-character U+1FFFF is not recommended for open interchange in print at - line 31.
475Unicode non-character U+2FFFE is not recommended for open interchange in print at - line 34.
476Unicode non-character U+2FFFF is not recommended for open interchange in print at - line 35.
477Unicode non-character U+3FFFE is not recommended for open interchange in print at - line 38.
478Unicode non-character U+3FFFF is not recommended for open interchange in print at - line 39.
479Unicode non-character U+4FFFE is not recommended for open interchange in print at - line 42.
480Unicode non-character U+4FFFF is not recommended for open interchange in print at - line 43.
481Unicode non-character U+5FFFE is not recommended for open interchange in print at - line 46.
482Unicode non-character U+5FFFF is not recommended for open interchange in print at - line 47.
483Unicode non-character U+6FFFE is not recommended for open interchange in print at - line 50.
484Unicode non-character U+6FFFF is not recommended for open interchange in print at - line 51.
485Unicode non-character U+7FFFE is not recommended for open interchange in print at - line 54.
486Unicode non-character U+7FFFF is not recommended for open interchange in print at - line 55.
487Unicode non-character U+8FFFE is not recommended for open interchange in print at - line 58.
488Unicode non-character U+8FFFF is not recommended for open interchange in print at - line 59.
489Unicode non-character U+9FFFE is not recommended for open interchange in print at - line 62.
490Unicode non-character U+9FFFF is not recommended for open interchange in print at - line 63.
491Unicode non-character U+AFFFE is not recommended for open interchange in print at - line 66.
492Unicode non-character U+AFFFF is not recommended for open interchange in print at - line 67.
493Unicode non-character U+BFFFE is not recommended for open interchange in print at - line 70.
494Unicode non-character U+BFFFF is not recommended for open interchange in print at - line 71.
495Unicode non-character U+CFFFE is not recommended for open interchange in print at - line 74.
496Unicode non-character U+CFFFF is not recommended for open interchange in print at - line 75.
497Unicode non-character U+DFFFE is not recommended for open interchange in print at - line 78.
498Unicode non-character U+DFFFF is not recommended for open interchange in print at - line 79.
499Unicode non-character U+EFFFE is not recommended for open interchange in print at - line 82.
500Unicode non-character U+EFFFF is not recommended for open interchange in print at - line 83.
501Unicode non-character U+FFFFE is not recommended for open interchange in print at - line 86.
502Unicode non-character U+FFFFF is not recommended for open interchange in print at - line 87.
503Unicode non-character U+10FFFE is not recommended for open interchange in print at - line 90.
504Unicode non-character U+10FFFF is not recommended for open interchange in print at - line 91.
505Code point 0x110000 is not Unicode, may not be portable in print at - line 92.
506Code point 0x11FFFD is not Unicode, may not be portable in print at - line 93.
507Code point 0x11FFFE is not Unicode, may not be portable in print at - line 94.
508Code point 0x11FFFF is not Unicode, may not be portable in print at - line 95.
509Code point 0x120000 is not Unicode, may not be portable in print at - line 96.
9ae3ac1a
KW
510########
511require "../test.pl";
8457b38f
KW
512use warnings 'utf8';
513my $file = tempfile();
514open(my $fh, "+>:utf8", $file);
515print $fh "\x{D800}", "\n";
516print $fh "\x{FFFF}", "\n";
517print $fh "\x{110000}", "\n";
518close $fh;
519EXPECT
520Unicode surrogate U+D800 is illegal in UTF-8 at - line 5.
15ca5930
KW
521Unicode non-character U+FFFF is not recommended for open interchange in print at - line 6.
522Code point 0x110000 is not Unicode, may not be portable in print at - line 7.
8457b38f
KW
523########
524require "../test.pl";
525use warnings 'utf8';
526no warnings 'surrogate';
527my $file = tempfile();
528open(my $fh, "+>:utf8", $file);
529print $fh "\x{D800}", "\n";
530print $fh "\x{FFFF}", "\n";
531print $fh "\x{110000}", "\n";
532close $fh;
533EXPECT
15ca5930
KW
534Unicode non-character U+FFFF is not recommended for open interchange in print at - line 7.
535Code point 0x110000 is not Unicode, may not be portable in print at - line 8.
8457b38f
KW
536########
537require "../test.pl";
538use warnings 'utf8';
539no warnings 'nonchar';
540my $file = tempfile();
541open(my $fh, "+>:utf8", $file);
542print $fh "\x{D800}", "\n";
543print $fh "\x{FFFF}", "\n";
544print $fh "\x{110000}", "\n";
545close $fh;
546EXPECT
547Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
15ca5930 548Code point 0x110000 is not Unicode, may not be portable in print at - line 8.
8457b38f
KW
549########
550require "../test.pl";
551use warnings 'utf8';
552no warnings 'non_unicode';
553my $file = tempfile();
554open(my $fh, "+>:utf8", $file);
555print $fh "\x{D800}", "\n";
556print $fh "\x{FFFF}", "\n";
557print $fh "\x{110000}", "\n";
558close $fh;
559EXPECT
560Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
15ca5930 561Unicode non-character U+FFFF is not recommended for open interchange in print at - line 7.
8457b38f 562########
920e47bb
AC
563# NAME C<use warnings "nonchar"> works in isolation
564require "../test.pl";
565use warnings 'nonchar';
566my $file = tempfile();
567open(my $fh, "+>:utf8", $file);
568print $fh "\x{FFFF}", "\n";
569close $fh;
570EXPECT
15ca5930 571Unicode non-character U+FFFF is not recommended for open interchange in print at - line 5.
920e47bb 572########
920e47bb
AC
573# NAME C<use warnings "surrogate"> works in isolation
574require "../test.pl";
575use warnings 'surrogate';
576my $file = tempfile();
577open(my $fh, "+>:utf8", $file);
578print $fh "\x{D800}", "\n";
579close $fh;
580EXPECT
581Unicode surrogate U+D800 is illegal in UTF-8 at - line 5.
582########
920e47bb
AC
583# NAME C<use warnings "non_unicode"> works in isolation
584require "../test.pl";
585use warnings 'non_unicode';
586my $file = tempfile();
587open(my $fh, "+>:utf8", $file);
588print $fh "\x{110000}", "\n";
589close $fh;
590EXPECT
15ca5930 591Code point 0x110000 is not Unicode, may not be portable in print at - line 5.
920e47bb 592########
8457b38f 593require "../test.pl";
9ae3ac1a
KW
594no warnings 'utf8';
595my $file = tempfile();
596open(my $fh, "+>:utf8", $file);
597print $fh "\x{D7FF}", "\n";
598print $fh "\x{D800}", "\n";
599print $fh "\x{DFFF}", "\n";
600print $fh "\x{E000}", "\n";
601print $fh "\x{FDCF}", "\n";
602print $fh "\x{FDD0}", "\n";
603print $fh "\x{FDEF}", "\n";
604print $fh "\x{FDF0}", "\n";
605print $fh "\x{FEFF}", "\n";
606print $fh "\x{FFFD}", "\n";
607print $fh "\x{FFFE}", "\n";
608print $fh "\x{FFFF}", "\n";
609print $fh "\x{10000}", "\n";
610print $fh "\x{1FFFE}", "\n";
611print $fh "\x{1FFFF}", "\n";
612print $fh "\x{2FFFE}", "\n";
613print $fh "\x{2FFFF}", "\n";
614print $fh "\x{3FFFE}", "\n";
615print $fh "\x{3FFFF}", "\n";
616print $fh "\x{4FFFE}", "\n";
617print $fh "\x{4FFFF}", "\n";
618print $fh "\x{5FFFE}", "\n";
619print $fh "\x{5FFFF}", "\n";
620print $fh "\x{6FFFE}", "\n";
621print $fh "\x{6FFFF}", "\n";
622print $fh "\x{7FFFE}", "\n";
623print $fh "\x{7FFFF}", "\n";
624print $fh "\x{8FFFE}", "\n";
625print $fh "\x{8FFFF}", "\n";
626print $fh "\x{9FFFE}", "\n";
627print $fh "\x{9FFFF}", "\n";
628print $fh "\x{AFFFE}", "\n";
629print $fh "\x{AFFFF}", "\n";
630print $fh "\x{BFFFE}", "\n";
631print $fh "\x{BFFFF}", "\n";
632print $fh "\x{CFFFE}", "\n";
633print $fh "\x{CFFFF}", "\n";
634print $fh "\x{DFFFE}", "\n";
635print $fh "\x{DFFFF}", "\n";
636print $fh "\x{EFFFE}", "\n";
637print $fh "\x{EFFFF}", "\n";
638print $fh "\x{FFFFE}", "\n";
639print $fh "\x{FFFFF}", "\n";
640print $fh "\x{100000}", "\n";
641print $fh "\x{10FFFE}", "\n";
642print $fh "\x{10FFFF}", "\n";
643print $fh "\x{110000}", "\n";
644close $fh;
62961d2e 645EXPECT
ab0b796c
KW
646########
647# NAME Case change crosses 255/256 under non-UTF8 locale
ef9d5242
KW
648require '../loc_tools.pl';
649unless (locales_enabled('LC_CTYPE')) {
650 print("SKIPPED\n# locales not available\n"),exit;
651}
ab0b796c
KW
652eval { require POSIX; POSIX->import("locale_h") };
653if ($@) {
654 print("SKIPPED\n# no POSIX\n"),exit;
655}
656use warnings 'locale';
657use feature 'fc';
658use locale;
659setlocale(&POSIX::LC_CTYPE, "C");
660my $a;
661$a = lc("\x{178}");
662$a = fc("\x{1E9E}");
663$a = fc("\x{FB05}");
664$a = uc("\x{FB00}");
665$a = ucfirst("\x{149}");
8bdce394
KW
666$a = lcfirst("\x{178}");
667no warnings 'locale';
668$a = lc("\x{178}");
669$a = fc("\x{1E9E}");
670$a = fc("\x{FB05}");
671$a = uc("\x{FB00}");
672$a = ucfirst("\x{149}");
673$a = lcfirst("\x{178}");
ab0b796c 674EXPECT
ef9d5242
KW
675Can't do lc("\x{178}") on non-UTF-8 locale; resolved to "\x{178}". at - line 14.
676Can't do fc("\x{1E9E}") on non-UTF-8 locale; resolved to "\x{17F}\x{17F}". at - line 15.
677Can't do fc("\x{FB05}") on non-UTF-8 locale; resolved to "\x{FB06}". at - line 16.
678Can't do uc("\x{FB00}") on non-UTF-8 locale; resolved to "\x{FB00}". at - line 17.
679Can't do ucfirst("\x{149}") on non-UTF-8 locale; resolved to "\x{149}". at - line 18.
680Can't do lcfirst("\x{178}") on non-UTF-8 locale; resolved to "\x{178}". at - line 19.
613abc6d
KW
681########
682# NAME Wide character in non-UTF-8 locale
ef9d5242
KW
683require '../loc_tools.pl';
684unless (locales_enabled('LC_CTYPE')) {
685 print("SKIPPED\n# locales not available\n"),exit;
686}
613abc6d
KW
687eval { require POSIX; POSIX->import("locale_h") };
688if ($@) {
689 print("SKIPPED\n# no POSIX\n"),exit;
690}
691use warnings 'locale';
692use feature 'fc';
693use locale;
694setlocale(&POSIX::LC_CTYPE, "C");
695my $a;
696$a = lc("\x{100}");
697$a = lcfirst("\x{101}");
698$a = fc("\x{102}");
699$a = uc("\x{103}");
700$a = ucfirst("\x{104}");
701no warnings 'locale';
702$a = lc("\x{100}");
703$a = lcfirst("\x{101}");
704$a = fc("\x{102}");
705$a = uc("\x{103}");
706$a = ucfirst("\x{104}");
707EXPECT
ef9d5242
KW
708Wide character (U+100) in lc at - line 14.
709Wide character (U+101) in lcfirst at - line 15.
710Wide character (U+102) in fc at - line 16.
711Wide character (U+103) in uc at - line 17.
712Wide character (U+104) in ucfirst at - line 18.
008e8e82
KW
713########
714# NAME Wide character in UTF-8 locale
715require '../loc_tools.pl';
716unless (locales_enabled('LC_CTYPE')) {
717 print("SKIPPED\n# locales not available\n"),exit;
718}
719eval { require POSIX; POSIX->import("locale_h") };
720if ($@) {
721 print("SKIPPED\n# no POSIX\n"),exit;
722}
723my @utf8_locales = find_utf8_ctype_locale();
724unless (@utf8_locales) {
725 print("SKIPPED\n# no UTF-8 locales\n"),exit;
726}
727use warnings 'locale';
728use feature 'fc';
729use locale;
730setlocale(&POSIX::LC_CTYPE, $utf8_locales[0]);
731my $a;
732$a = lc("\x{100}");
733$a = lcfirst("\x{101}");
734$a = fc("\x{102}");
735$a = uc("\x{103}");
736$a = ucfirst("\x{104}");
737EXPECT
760c7c2f
KW
738########
739# NAME Deprecation of too-large code points
740require "../test.pl";
741use warnings 'non_unicode';
742my $max_cp = ~0 >> 1;
743my $max_char = chr $max_cp;
744my $to_warn_cp = $max_cp + 1;
745my $to_warn_char = chr $to_warn_cp;
746$max_char =~ /[\x{110000}\P{Unassigned}]/;
747$to_warn_char =~ /[\x{110000}\P{Unassigned}]/;
748my $temp = qr/$max_char/;
749$temp = qr/$to_warn_char/;
750$temp = uc($max_char);
751$temp = uc($to_warn_char);
752my $file = tempfile();
753open(my $fh, "+>:utf8", $file);
754print $fh $max_char, "\n";
755print $fh $to_warn_char, "\n";
756close $fh;
757EXPECT
758OPTION regex
fcdb3ac1
A
759Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 at - line \d+.
760Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in pattern match \(m//\) at - line \d+.
761Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in regexp compilation at - line \d+.
762Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in regexp compilation at - line \d+.
763Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 at - line \d+.
764Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in regexp compilation at - line \d+.
760c7c2f 765Operation "uc" returns its argument for non-Unicode code point 0x7F+ at - line \d+.
fcdb3ac1
A
766Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in uc at - line \d+.
767Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 at - line \d+.
760c7c2f
KW
768Operation "uc" returns its argument for non-Unicode code point 0x80+ at - line \d+.
769Code point 0x7F+ is not Unicode, may not be portable in print at - line \d+.
fcdb3ac1 770Use of code point 0x80+ is deprecated; the permissible max is 0x7F+\. This will be fatal in Perl 5\.28 in print at - line \d+.
710740a6
KW
771########
772# NAME [perl #127262]
e88136ce
KW
773BEGIN{
774 if (ord('A') == 193) {
775 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
776 exit 0;
777 }
a8b2934d
JH
778 use Config;
779 unless ($Double{double_style_ieee}) {
780 print "SKIPPED\n# non-IEEE fp range.";
781 exit 0;
782 }
783{};$^H=eval'2**400'}Â
710740a6 784EXPECT
a8b2934d 785Malformed UTF-8 character: \xc2\x0a (unexpected non-continuation byte 0x0a, immediately after start byte 0xc2; need 2 bytes, got 1) at - line 11.