This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #124153] Fix require(v5.6)
[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
f0df466a
JH
18BEGIN {
19 if (ord('A') == 193) {
72b4e0d1 20 print "SKIPPED\n# ebcdic platforms generates different Malformed UTF-8 warnings.";
f0df466a
JH
21 exit 0;
22 }
23}
24use utf8 ;
25my $a = "snøstorm" ;
26{
27 no warnings 'utf8' ;
28 my $a = "snøstorm";
29 use warnings 'utf8' ;
30 my $a = "snøstorm";
31}
32EXPECT
41432148
JH
33Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 9.
34Malformed UTF-8 character (unexpected non-continuation byte 0x73, immediately after start byte 0xf8) at - line 14.
f0df466a 35########
507b9800 36use warnings 'utf8';
9ae3ac1a
KW
37my $d7ff = uc(chr(0xD7FF));
38my $d800 = uc(chr(0xD800));
39my $dfff = uc(chr(0xDFFF));
40my $e000 = uc(chr(0xE000));
41my $feff = uc(chr(0xFEFF));
42my $fffd = uc(chr(0xFFFD));
43my $fffe = uc(chr(0xFFFE));
44my $ffff = uc(chr(0xFFFF));
45my $hex4 = uc(chr(0x10000));
46my $hex5 = uc(chr(0x100000));
47my $maxm1 = uc(chr(0x10FFFE));
48my $max = uc(chr(0x10FFFF));
49my $nonUnicode = uc(chr(0x110000));
507b9800 50no warnings 'utf8';
9ae3ac1a
KW
51my $d7ff = uc(chr(0xD7FF));
52my $d800 = uc(chr(0xD800));
53my $dfff = uc(chr(0xDFFF));
54my $e000 = uc(chr(0xE000));
55my $feff = uc(chr(0xFEFF));
56my $fffd = uc(chr(0xFFFD));
57my $fffe = uc(chr(0xFFFE));
58my $ffff = uc(chr(0xFFFF));
59my $hex4 = uc(chr(0x10000));
60my $hex5 = uc(chr(0x100000));
61my $maxm1 = uc(chr(0x10FFFE));
62my $max = uc(chr(0x10FFFF));
63my $nonUnicode = uc(chr(0x110000));
507b9800 64EXPECT
9ae3ac1a
KW
65Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
66Operation "uc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
67Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 14.
507b9800 68########
62961d2e 69use warnings 'utf8';
8457b38f
KW
70my $d800 = uc(chr(0xD800));
71my $nonUnicode = uc(chr(0x110000));
72no warnings 'surrogate';
73my $d800 = uc(chr(0xD800));
74my $nonUnicode = uc(chr(0x110000));
75EXPECT
76Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 2.
77Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 3.
78Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 6.
79########
80use warnings 'utf8';
81my $d800 = uc(chr(0xD800));
82my $nonUnicode = uc(chr(0x110000));
8457b38f
KW
83no warnings 'non_unicode';
84my $d800 = uc(chr(0xD800));
85my $nonUnicode = uc(chr(0x110000));
8457b38f
KW
86EXPECT
87Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 2.
88Operation "uc" returns its argument for non-Unicode code point 0x110000 at - line 3.
9415f659
KW
89Operation "uc" returns its argument for UTF-16 surrogate U+D800 at - line 5.
90########
91BEGIN {
92 if (ord('A') == 193) {
93 print "SKIPPED\n# ebcdic platforms can't handle this large a code point";
94 exit 0;
95 }
96}
97use warnings 'utf8';
98my $big_nonUnicode = uc(chr(0x8000_0000));
99no warnings 'non_unicode';
100my $big_nonUnicode = uc(chr(0x8000_0000));
101EXPECT
102Operation "uc" returns its argument for non-Unicode code point 0x80000000 at - line 8.
8457b38f
KW
103########
104use warnings 'utf8';
9ae3ac1a
KW
105my $d7ff = lc pack("U", 0xD7FF);
106my $d800 = lc pack("U", 0xD800);
107my $dfff = lc pack("U", 0xDFFF);
108my $e000 = lc pack("U", 0xE000);
109my $feff = lc pack("U", 0xFEFF);
110my $fffd = lc pack("U", 0xFFFD);
111my $fffe = lc pack("U", 0xFFFE);
112my $ffff = lc pack("U", 0xFFFF);
113my $hex4 = lc pack("U", 0x10000);
114my $hex5 = lc pack("U", 0x100000);
115my $maxm1 = lc pack("U", 0x10FFFE);
116my $max = lc pack("U", 0x10FFFF);
117my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 118no warnings 'utf8';
9ae3ac1a
KW
119my $d7ff = lc pack("U", 0xD7FF);
120my $d800 = lc pack("U", 0xD800);
121my $dfff = lc pack("U", 0xDFFF);
122my $e000 = lc pack("U", 0xE000);
123my $feff = lc pack("U", 0xFEFF);
124my $fffd = lc pack("U", 0xFFFD);
125my $fffe = lc pack("U", 0xFFFE);
126my $ffff = lc pack("U", 0xFFFF);
127my $hex4 = lc pack("U", 0x10000);
128my $hex5 = lc pack("U", 0x100000);
129my $maxm1 = lc pack("U", 0x10FFFE);
130my $max = lc pack("U", 0x10FFFF);
131my $nonUnicode = lc(pack("U", 0x110000));
62961d2e 132EXPECT
9ae3ac1a
KW
133Operation "lc" returns its argument for UTF-16 surrogate U+D800 at - line 3.
134Operation "lc" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
135Operation "lc" returns its argument for non-Unicode code point 0x110000 at - line 14.
62961d2e
JH
136########
137use warnings 'utf8';
9ae3ac1a
KW
138my $d7ff = ucfirst "\x{D7FF}";
139my $d800 = ucfirst "\x{D800}";
140my $dfff = ucfirst "\x{DFFF}";
141my $e000 = ucfirst "\x{E000}";
142my $feff = ucfirst "\x{FEFF}";
143my $fffd = ucfirst "\x{FFFD}";
144my $fffe = ucfirst "\x{FFFE}";
145my $ffff = ucfirst "\x{FFFF}";
146my $hex4 = ucfirst "\x{10000}";
147my $hex5 = ucfirst "\x{100000}";
148my $maxm1 = ucfirst "\x{10FFFE}";
149my $max = ucfirst "\x{10FFFF}";
150my $nonUnicode = ucfirst "\x{110000}";
62961d2e 151no warnings 'utf8';
9ae3ac1a
KW
152my $d7ff = ucfirst "\x{D7FF}";
153my $d800 = ucfirst "\x{D800}";
154my $dfff = ucfirst "\x{DFFF}";
155my $e000 = ucfirst "\x{E000}";
156my $feff = ucfirst "\x{FEFF}";
157my $fffd = ucfirst "\x{FFFD}";
158my $fffe = ucfirst "\x{FFFE}";
159my $ffff = ucfirst "\x{FFFF}";
160my $hex4 = ucfirst "\x{10000}";
161my $hex5 = ucfirst "\x{100000}";
162my $maxm1 = ucfirst "\x{10FFFE}";
163my $max = ucfirst "\x{10FFFF}";
164my $nonUnicode = ucfirst "\x{110000}";
165EXPECT
166Operation "ucfirst" returns its argument for UTF-16 surrogate U+D800 at - line 3.
167Operation "ucfirst" returns its argument for UTF-16 surrogate U+DFFF at - line 4.
168Operation "ucfirst" returns its argument for non-Unicode code point 0x110000 at - line 14.
169########
2d88a86a 170# NAME Matching \p{} against above-Unicode
9ae3ac1a
KW
171use warnings 'utf8';
172chr(0xD7FF) =~ /\p{Any}/;
173chr(0xD800) =~ /\p{Any}/;
174chr(0xDFFF) =~ /\p{Any}/;
175chr(0xE000) =~ /\p{Any}/;
176chr(0xFEFF) =~ /\p{Any}/;
177chr(0xFFFD) =~ /\p{Any}/;
178chr(0xFFFE) =~ /\p{Any}/;
179chr(0xFFFF) =~ /\p{Any}/;
180chr(0x10000) =~ /\p{Any}/;
181chr(0x100000) =~ /\p{Any}/;
182chr(0x10FFFE) =~ /\p{Any}/;
183chr(0x10FFFF) =~ /\p{Any}/;
2d88a86a
KW
184chr(0x110000) =~ /[\p{Any}]/;
185chr(0x110001) =~ /[\w\p{Any}]/;
186chr(0x10FFFF) =~ /\p{All}/;
187chr(0x110002) =~ /[\w\p{All}]/;
188chr(0x110003) =~ /[\p{XPosixWord}]/;
189chr(0x110004) =~ /[\P{XPosixWord}]/;
190chr(0x110005) =~ /^[\p{Unassigned}]/;
191chr(0x110006) =~ /^[\P{Unassigned}]/;
192# Only Unicode properties give non-Unicode warnings, and only those properties
193# which do match above Unicode; and not when something else in the class
194# matches above Unicode. Below we test three ways where something outside the
195# property may match non-Unicode: a code point above it, a class \S that we
196# know at compile time doesn't, and a class \W whose values aren't (at the time
197# of this writing) specified at compile time, but which wouldn't match
5073ffbd
KW
198chr(0x110050) =~ /\w/;
199chr(0x110051) =~ /\W/;
200chr(0x110052) =~ /\d/;
201chr(0x110053) =~ /\D/;
202chr(0x110054) =~ /\s/;
203chr(0x110055) =~ /\S/;
204chr(0x110056) =~ /[[:word:]]/;
205chr(0x110057) =~ /[[:^word:]]/;
206chr(0x110058) =~ /[[:alnum:]]/;
207chr(0x110059) =~ /[[:^alnum:]]/;
208chr(0x11005A) =~ /[[:space:]]/;
209chr(0x11005B) =~ /[[:^space:]]/;
210chr(0x11005C) =~ /[[:digit:]]/;
211chr(0x11005D) =~ /[[:^digit:]]/;
212chr(0x11005E) =~ /[[:alpha:]]/;
213chr(0x11005F) =~ /[[:^alpha:]]/;
214chr(0x110060) =~ /[[:ascii:]]/;
215chr(0x110061) =~ /[[:^ascii:]]/;
216chr(0x110062) =~ /[[:cntrl:]]/;
217chr(0x110063) =~ /[[:^cntrl:]]/;
218chr(0x110064) =~ /[[:graph:]]/;
219chr(0x110065) =~ /[[:^graph:]]/;
220chr(0x110066) =~ /[[:lower:]]/;
221chr(0x110067) =~ /[[:^lower:]]/;
222chr(0x110068) =~ /[[:print:]]/;
223chr(0x110069) =~ /[[:^print:]]/;
224chr(0x11006A) =~ /[[:punct:]]/;
225chr(0x11006B) =~ /[[:^punct:]]/;
226chr(0x11006C) =~ /[[:upper:]]/;
227chr(0x11006D) =~ /[[:^upper:]]/;
228chr(0x11006E) =~ /[[:xdigit:]]/;
229chr(0x11006F) =~ /[[:^xdigit:]]/;
230chr(0x110070) =~ /[[:blank:]]/;
231chr(0x110071) =~ /[[:^blank:]]/;
2d88a86a
KW
232chr(0x111010) =~ /[\W\p{Unassigned}]/;
233chr(0x111011) =~ /[\W\P{Unassigned}]/;
234chr(0x112010) =~ /[\S\p{Unassigned}]/;
235chr(0x112011) =~ /[\S\P{Unassigned}]/;
236chr(0x113010) =~ /[\x{110000}\p{Unassigned}]/;
237chr(0x113011) =~ /[\x{110000}\P{Unassigned}]/;
9ae3ac1a
KW
238no warnings 'utf8';
239chr(0xD7FF) =~ /\p{Any}/;
240chr(0xD800) =~ /\p{Any}/;
241chr(0xDFFF) =~ /\p{Any}/;
242chr(0xE000) =~ /\p{Any}/;
243chr(0xFEFF) =~ /\p{Any}/;
244chr(0xFFFD) =~ /\p{Any}/;
245chr(0xFFFE) =~ /\p{Any}/;
246chr(0xFFFF) =~ /\p{Any}/;
247chr(0x10000) =~ /\p{Any}/;
248chr(0x100000) =~ /\p{Any}/;
249chr(0x10FFFE) =~ /\p{Any}/;
250chr(0x10FFFF) =~ /\p{Any}/;
2d88a86a
KW
251chr(0x110000) =~ /[\p{Any}]/;
252chr(0x110001) =~ /[\w\p{Any}]/;
253chr(0x10FFFF) =~ /\p{All}/;
254chr(0x110002) =~ /[\w\p{All}]/;
255chr(0x110003) =~ /[\p{XPosixWord}]/;
256chr(0x110004) =~ /[\P{XPosixWord}]/;
257chr(0x110005) =~ /^[\p{Unassigned}]/;
258chr(0x110006) =~ /^[\P{Unassigned}]/;
5073ffbd
KW
259chr(0x110050) =~ /\w/;
260chr(0x110051) =~ /\W/;
261chr(0x110052) =~ /\d/;
262chr(0x110053) =~ /\D/;
263chr(0x110054) =~ /\s/;
264chr(0x110055) =~ /\S/;
265chr(0x110056) =~ /[[:word:]]/;
266chr(0x110057) =~ /[[:^word:]]/;
267chr(0x110058) =~ /[[:alnum:]]/;
268chr(0x110059) =~ /[[:^alnum:]]/;
269chr(0x11005A) =~ /[[:space:]]/;
270chr(0x11005B) =~ /[[:^space:]]/;
271chr(0x11005C) =~ /[[:digit:]]/;
272chr(0x11005D) =~ /[[:^digit:]]/;
273chr(0x11005E) =~ /[[:alpha:]]/;
274chr(0x11005F) =~ /[[:^alpha:]]/;
275chr(0x110060) =~ /[[:ascii:]]/;
276chr(0x110061) =~ /[[:^ascii:]]/;
277chr(0x110062) =~ /[[:cntrl:]]/;
278chr(0x110063) =~ /[[:^cntrl:]]/;
279chr(0x110064) =~ /[[:graph:]]/;
280chr(0x110065) =~ /[[:^graph:]]/;
281chr(0x110066) =~ /[[:lower:]]/;
282chr(0x110067) =~ /[[:^lower:]]/;
283chr(0x110068) =~ /[[:print:]]/;
284chr(0x110069) =~ /[[:^print:]]/;
285chr(0x11006A) =~ /[[:punct:]]/;
286chr(0x11006B) =~ /[[:^punct:]]/;
287chr(0x11006C) =~ /[[:upper:]]/;
288chr(0x11006D) =~ /[[:^upper:]]/;
289chr(0x11006E) =~ /[[:xdigit:]]/;
290chr(0x11006F) =~ /[[:^xdigit:]]/;
291chr(0x110070) =~ /[[:blank:]]/;
292chr(0x110071) =~ /[[:^blank:]]/;
2d88a86a
KW
293chr(0x111010) =~ /[\W\p{Unassigned}]/;
294chr(0x111011) =~ /[\W\P{Unassigned}]/;
295chr(0x112010) =~ /[\S\p{Unassigned}]/;
296chr(0x112011) =~ /[\S\P{Unassigned}]/;
297chr(0x113010) =~ /[\x{110000}\p{Unassigned}]/;
298chr(0x113011) =~ /[\x{110000}\P{Unassigned}]/;
9ae3ac1a 299EXPECT
2d88a86a
KW
300Matched non-Unicode code point 0x110005 against Unicode property; may not be portable at - line 20.
301Matched non-Unicode code point 0x110006 against Unicode property; may not be portable at - line 21.
9ae3ac1a 302########
e9b08962 303# NAME Matching Unicode property against above-Unicode code point outputs a warning even if optimizer rejects the match (in synthetic start class)
2d88a86a
KW
304# Now have to make FATAL to guarantee being output
305use warnings FATAL => 'non_unicode';
ae986089
KW
306"\x{110000}" =~ /b?\p{Space}/;
307EXPECT
2d88a86a 308Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 3.
ae986089
KW
309########
310# NAME Matching POSIX class property against above-Unicode code point doesn't output a warning
311use warnings 'non_unicode';
2d88a86a 312use warnings FATAL => 'non_unicode';
ae986089
KW
313"\x{110000}" =~ /b?[[:space:]]/;
314EXPECT
315########
8457b38f
KW
316use warnings 'utf8';
317chr(0x110000) =~ /\p{Any}/;
2d88a86a
KW
318########
319# NAME utf8, non_unicode warnings categories work on Matched non-Unicode code point warning
320use warnings qw(utf8 non_unicode);
321chr(0x110000) =~ /^\p{Unassigned}/;
8457b38f 322no warnings 'non_unicode';
2d88a86a
KW
323chr(0x110001) =~ /\p{Unassigned}/;
324use warnings 'non_unicode';
325no warnings 'utf8';
326chr(0x110002) =~ /\p{Unassigned}/;
8457b38f 327EXPECT
2d88a86a 328Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 2.
8457b38f 329########
f2c2a6ab 330# NAME optimizable regnode should still give non_unicode warnings when fatalized
5073ffbd 331use warnings 'utf8';
f2c2a6ab 332use warnings FATAL => 'non_unicode';
845e7aa3 333chr(0x110000) =~ /\p{lb=cr}/;
f2c2a6ab 334EXPECT
2d88a86a 335Matched non-Unicode code point 0x110000 against Unicode property; may not be portable at - line 3.
f2c2a6ab
KW
336########
337# NAME optimizable regnode should not give non_unicode warnings when warnings are off
5073ffbd 338no warnings 'non_unicode';
845e7aa3 339chr(0x110000) =~ /\p{lb=cr}/;
5073ffbd 340EXPECT
5073ffbd 341########
2d88a86a
KW
342# NAME 'All' matches above-Unicode without any warning
343use warnings qw(utf8 non_unicode);
344chr(0x110000) =~ /\p{All}/;
345EXPECT
346########
9ae3ac1a
KW
347require "../test.pl";
348use warnings 'utf8';
a410ec23 349sub Is_Super { return '!utf8::Any' }
88d45d28
KW
350# The extra char is to avoid an optimization that avoids the problem when the
351# property is the only non-latin1 char in a class
352print "\x{1100000}" =~ /^[\p{Is_Super}\x{100}]$/, "\n";
a410ec23
KW
353EXPECT
3541
355########
356require "../test.pl";
357use warnings 'utf8';
9ae3ac1a
KW
358my $file = tempfile();
359open(my $fh, "+>:utf8", $file);
360print $fh "\x{D7FF}", "\n";
361print $fh "\x{D800}", "\n";
362print $fh "\x{DFFF}", "\n";
363print $fh "\x{E000}", "\n";
364print $fh "\x{FDCF}", "\n";
365print $fh "\x{FDD0}", "\n";
366print $fh "\x{FDEF}", "\n";
367print $fh "\x{FDF0}", "\n";
368print $fh "\x{FEFF}", "\n";
369print $fh "\x{FFFD}", "\n";
370print $fh "\x{FFFE}", "\n";
371print $fh "\x{FFFF}", "\n";
372print $fh "\x{10000}", "\n";
373print $fh "\x{1FFFE}", "\n";
374print $fh "\x{1FFFF}", "\n";
375print $fh "\x{2FFFE}", "\n";
376print $fh "\x{2FFFF}", "\n";
377print $fh "\x{3FFFE}", "\n";
378print $fh "\x{3FFFF}", "\n";
379print $fh "\x{4FFFE}", "\n";
380print $fh "\x{4FFFF}", "\n";
381print $fh "\x{5FFFE}", "\n";
382print $fh "\x{5FFFF}", "\n";
383print $fh "\x{6FFFE}", "\n";
384print $fh "\x{6FFFF}", "\n";
385print $fh "\x{7FFFE}", "\n";
386print $fh "\x{7FFFF}", "\n";
387print $fh "\x{8FFFE}", "\n";
388print $fh "\x{8FFFF}", "\n";
389print $fh "\x{9FFFE}", "\n";
390print $fh "\x{9FFFF}", "\n";
391print $fh "\x{AFFFE}", "\n";
392print $fh "\x{AFFFF}", "\n";
393print $fh "\x{BFFFE}", "\n";
394print $fh "\x{BFFFF}", "\n";
395print $fh "\x{CFFFE}", "\n";
396print $fh "\x{CFFFF}", "\n";
397print $fh "\x{DFFFE}", "\n";
398print $fh "\x{DFFFF}", "\n";
399print $fh "\x{EFFFE}", "\n";
400print $fh "\x{EFFFF}", "\n";
401print $fh "\x{FFFFE}", "\n";
402print $fh "\x{FFFFF}", "\n";
403print $fh "\x{100000}", "\n";
404print $fh "\x{10FFFE}", "\n";
405print $fh "\x{10FFFF}", "\n";
406print $fh "\x{110000}", "\n";
407close $fh;
408EXPECT
409Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
410Unicode surrogate U+DFFF is illegal in UTF-8 at - line 7.
411Unicode non-character U+FDD0 is illegal for open interchange at - line 10.
412Unicode non-character U+FDEF is illegal for open interchange at - line 11.
413Unicode non-character U+FFFE is illegal for open interchange at - line 15.
414Unicode non-character U+FFFF is illegal for open interchange at - line 16.
415Unicode non-character U+1FFFE is illegal for open interchange at - line 18.
416Unicode non-character U+1FFFF is illegal for open interchange at - line 19.
417Unicode non-character U+2FFFE is illegal for open interchange at - line 20.
418Unicode non-character U+2FFFF is illegal for open interchange at - line 21.
419Unicode non-character U+3FFFE is illegal for open interchange at - line 22.
420Unicode non-character U+3FFFF is illegal for open interchange at - line 23.
421Unicode non-character U+4FFFE is illegal for open interchange at - line 24.
422Unicode non-character U+4FFFF is illegal for open interchange at - line 25.
423Unicode non-character U+5FFFE is illegal for open interchange at - line 26.
424Unicode non-character U+5FFFF is illegal for open interchange at - line 27.
425Unicode non-character U+6FFFE is illegal for open interchange at - line 28.
426Unicode non-character U+6FFFF is illegal for open interchange at - line 29.
427Unicode non-character U+7FFFE is illegal for open interchange at - line 30.
428Unicode non-character U+7FFFF is illegal for open interchange at - line 31.
429Unicode non-character U+8FFFE is illegal for open interchange at - line 32.
430Unicode non-character U+8FFFF is illegal for open interchange at - line 33.
431Unicode non-character U+9FFFE is illegal for open interchange at - line 34.
432Unicode non-character U+9FFFF is illegal for open interchange at - line 35.
433Unicode non-character U+AFFFE is illegal for open interchange at - line 36.
434Unicode non-character U+AFFFF is illegal for open interchange at - line 37.
435Unicode non-character U+BFFFE is illegal for open interchange at - line 38.
436Unicode non-character U+BFFFF is illegal for open interchange at - line 39.
437Unicode non-character U+CFFFE is illegal for open interchange at - line 40.
438Unicode non-character U+CFFFF is illegal for open interchange at - line 41.
439Unicode non-character U+DFFFE is illegal for open interchange at - line 42.
440Unicode non-character U+DFFFF is illegal for open interchange at - line 43.
441Unicode non-character U+EFFFE is illegal for open interchange at - line 44.
442Unicode non-character U+EFFFF is illegal for open interchange at - line 45.
443Unicode non-character U+FFFFE is illegal for open interchange at - line 46.
444Unicode non-character U+FFFFF is illegal for open interchange at - line 47.
445Unicode non-character U+10FFFE is illegal for open interchange at - line 49.
446Unicode non-character U+10FFFF is illegal for open interchange at - line 50.
447Code point 0x110000 is not Unicode, may not be portable at - line 51.
448########
449require "../test.pl";
8457b38f
KW
450use warnings 'utf8';
451my $file = tempfile();
452open(my $fh, "+>:utf8", $file);
453print $fh "\x{D800}", "\n";
454print $fh "\x{FFFF}", "\n";
455print $fh "\x{110000}", "\n";
456close $fh;
457EXPECT
458Unicode surrogate U+D800 is illegal in UTF-8 at - line 5.
459Unicode non-character U+FFFF is illegal for open interchange at - line 6.
460Code point 0x110000 is not Unicode, may not be portable at - line 7.
461########
462require "../test.pl";
463use warnings 'utf8';
464no warnings 'surrogate';
465my $file = tempfile();
466open(my $fh, "+>:utf8", $file);
467print $fh "\x{D800}", "\n";
468print $fh "\x{FFFF}", "\n";
469print $fh "\x{110000}", "\n";
470close $fh;
471EXPECT
472Unicode non-character U+FFFF is illegal for open interchange at - line 7.
473Code point 0x110000 is not Unicode, may not be portable at - line 8.
474########
475require "../test.pl";
476use warnings 'utf8';
477no warnings 'nonchar';
478my $file = tempfile();
479open(my $fh, "+>:utf8", $file);
480print $fh "\x{D800}", "\n";
481print $fh "\x{FFFF}", "\n";
482print $fh "\x{110000}", "\n";
483close $fh;
484EXPECT
485Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
486Code point 0x110000 is not Unicode, may not be portable at - line 8.
487########
488require "../test.pl";
489use warnings 'utf8';
490no warnings 'non_unicode';
491my $file = tempfile();
492open(my $fh, "+>:utf8", $file);
493print $fh "\x{D800}", "\n";
494print $fh "\x{FFFF}", "\n";
495print $fh "\x{110000}", "\n";
496close $fh;
497EXPECT
498Unicode surrogate U+D800 is illegal in UTF-8 at - line 6.
499Unicode non-character U+FFFF is illegal for open interchange at - line 7.
500########
920e47bb
AC
501# NAME C<use warnings "nonchar"> works in isolation
502require "../test.pl";
503use warnings 'nonchar';
504my $file = tempfile();
505open(my $fh, "+>:utf8", $file);
506print $fh "\x{FFFF}", "\n";
507close $fh;
508EXPECT
509Unicode non-character U+FFFF is illegal for open interchange at - line 5.
510########
920e47bb
AC
511# NAME C<use warnings "surrogate"> works in isolation
512require "../test.pl";
513use warnings 'surrogate';
514my $file = tempfile();
515open(my $fh, "+>:utf8", $file);
516print $fh "\x{D800}", "\n";
517close $fh;
518EXPECT
519Unicode surrogate U+D800 is illegal in UTF-8 at - line 5.
520########
920e47bb
AC
521# NAME C<use warnings "non_unicode"> works in isolation
522require "../test.pl";
523use warnings 'non_unicode';
524my $file = tempfile();
525open(my $fh, "+>:utf8", $file);
526print $fh "\x{110000}", "\n";
527close $fh;
528EXPECT
529Code point 0x110000 is not Unicode, may not be portable at - line 5.
530########
8457b38f 531require "../test.pl";
9ae3ac1a
KW
532no warnings 'utf8';
533my $file = tempfile();
534open(my $fh, "+>:utf8", $file);
535print $fh "\x{D7FF}", "\n";
536print $fh "\x{D800}", "\n";
537print $fh "\x{DFFF}", "\n";
538print $fh "\x{E000}", "\n";
539print $fh "\x{FDCF}", "\n";
540print $fh "\x{FDD0}", "\n";
541print $fh "\x{FDEF}", "\n";
542print $fh "\x{FDF0}", "\n";
543print $fh "\x{FEFF}", "\n";
544print $fh "\x{FFFD}", "\n";
545print $fh "\x{FFFE}", "\n";
546print $fh "\x{FFFF}", "\n";
547print $fh "\x{10000}", "\n";
548print $fh "\x{1FFFE}", "\n";
549print $fh "\x{1FFFF}", "\n";
550print $fh "\x{2FFFE}", "\n";
551print $fh "\x{2FFFF}", "\n";
552print $fh "\x{3FFFE}", "\n";
553print $fh "\x{3FFFF}", "\n";
554print $fh "\x{4FFFE}", "\n";
555print $fh "\x{4FFFF}", "\n";
556print $fh "\x{5FFFE}", "\n";
557print $fh "\x{5FFFF}", "\n";
558print $fh "\x{6FFFE}", "\n";
559print $fh "\x{6FFFF}", "\n";
560print $fh "\x{7FFFE}", "\n";
561print $fh "\x{7FFFF}", "\n";
562print $fh "\x{8FFFE}", "\n";
563print $fh "\x{8FFFF}", "\n";
564print $fh "\x{9FFFE}", "\n";
565print $fh "\x{9FFFF}", "\n";
566print $fh "\x{AFFFE}", "\n";
567print $fh "\x{AFFFF}", "\n";
568print $fh "\x{BFFFE}", "\n";
569print $fh "\x{BFFFF}", "\n";
570print $fh "\x{CFFFE}", "\n";
571print $fh "\x{CFFFF}", "\n";
572print $fh "\x{DFFFE}", "\n";
573print $fh "\x{DFFFF}", "\n";
574print $fh "\x{EFFFE}", "\n";
575print $fh "\x{EFFFF}", "\n";
576print $fh "\x{FFFFE}", "\n";
577print $fh "\x{FFFFF}", "\n";
578print $fh "\x{100000}", "\n";
579print $fh "\x{10FFFE}", "\n";
580print $fh "\x{10FFFF}", "\n";
581print $fh "\x{110000}", "\n";
582close $fh;
62961d2e 583EXPECT
ab0b796c
KW
584########
585# NAME Case change crosses 255/256 under non-UTF8 locale
ef9d5242
KW
586require '../loc_tools.pl';
587unless (locales_enabled('LC_CTYPE')) {
588 print("SKIPPED\n# locales not available\n"),exit;
589}
ab0b796c
KW
590eval { require POSIX; POSIX->import("locale_h") };
591if ($@) {
592 print("SKIPPED\n# no POSIX\n"),exit;
593}
594use warnings 'locale';
595use feature 'fc';
596use locale;
597setlocale(&POSIX::LC_CTYPE, "C");
598my $a;
599$a = lc("\x{178}");
600$a = fc("\x{1E9E}");
601$a = fc("\x{FB05}");
602$a = uc("\x{FB00}");
603$a = ucfirst("\x{149}");
8bdce394
KW
604$a = lcfirst("\x{178}");
605no warnings 'locale';
606$a = lc("\x{178}");
607$a = fc("\x{1E9E}");
608$a = fc("\x{FB05}");
609$a = uc("\x{FB00}");
610$a = ucfirst("\x{149}");
611$a = lcfirst("\x{178}");
ab0b796c 612EXPECT
ef9d5242
KW
613Can't do lc("\x{178}") on non-UTF-8 locale; resolved to "\x{178}". at - line 14.
614Can't do fc("\x{1E9E}") on non-UTF-8 locale; resolved to "\x{17F}\x{17F}". at - line 15.
615Can't do fc("\x{FB05}") on non-UTF-8 locale; resolved to "\x{FB06}". at - line 16.
616Can't do uc("\x{FB00}") on non-UTF-8 locale; resolved to "\x{FB00}". at - line 17.
617Can't do ucfirst("\x{149}") on non-UTF-8 locale; resolved to "\x{149}". at - line 18.
618Can't do lcfirst("\x{178}") on non-UTF-8 locale; resolved to "\x{178}". at - line 19.
613abc6d
KW
619########
620# NAME Wide character in non-UTF-8 locale
ef9d5242
KW
621require '../loc_tools.pl';
622unless (locales_enabled('LC_CTYPE')) {
623 print("SKIPPED\n# locales not available\n"),exit;
624}
613abc6d
KW
625eval { require POSIX; POSIX->import("locale_h") };
626if ($@) {
627 print("SKIPPED\n# no POSIX\n"),exit;
628}
629use warnings 'locale';
630use feature 'fc';
631use locale;
632setlocale(&POSIX::LC_CTYPE, "C");
633my $a;
634$a = lc("\x{100}");
635$a = lcfirst("\x{101}");
636$a = fc("\x{102}");
637$a = uc("\x{103}");
638$a = ucfirst("\x{104}");
639no warnings 'locale';
640$a = lc("\x{100}");
641$a = lcfirst("\x{101}");
642$a = fc("\x{102}");
643$a = uc("\x{103}");
644$a = ucfirst("\x{104}");
645EXPECT
ef9d5242
KW
646Wide character (U+100) in lc at - line 14.
647Wide character (U+101) in lcfirst at - line 15.
648Wide character (U+102) in fc at - line 16.
649Wide character (U+103) in uc at - line 17.
650Wide character (U+104) in ucfirst at - line 18.