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