3 # These tests are in a separate file, because they use fresh_perl_is()
6 # The mb* functions use the "underlying locale" that is not affected by
7 # the Perl one. So we run the tests in a separate "fresh_perl" process
8 # with the correct LC_CTYPE set in the environment.
11 require Config; import Config;
12 if ($^O ne 'VMS' and $Config{'extensions'} !~ /\bPOSIX\b/) {
16 unshift @INC, "../../t";
17 require 'loc_tools.pl';
18 require 'charset_tools.pl';
27 skip("mblen() not present", 4) unless $Config{d_mblen};
29 is(&POSIX::mblen("a", &POSIX::MB_CUR_MAX), 1, 'mblen() basically works');
31 skip("LC_CTYPE locale support not available", 3)
32 unless locales_enabled('LC_CTYPE');
34 my $utf8_locale = find_utf8_ctype_locale();
35 skip("no utf8 locale available", 3) unless $utf8_locale;
37 local $ENV{LC_CTYPE} = $utf8_locale;
42 'use POSIX; print &POSIX::MB_CUR_MAX',
43 qr/[4-6]/, {}, 'MB_CUR_MAX is at least 4 in a UTF-8 locale');
46 my ($major, $minor, $rest) = $Config{osvers} =~ / (\d+) \. (\d+) .* /x;
47 skip("mblen() broken (at least for c.utf8) on early HP-UX", 1)
48 if $Config{osname} eq 'hpux'
49 && $major < 11 || ($major == 11 && $minor < 31);
51 'use POSIX; print &POSIX::mblen("'
52 . I8_to_native("\x{c3}\x{28}")
54 -1, {}, 'mblen() recognizes invalid multibyte characters');
58 'use POSIX; print &POSIX::mblen("\N{GREEK SMALL LETTER SIGMA}", 2)',
59 2, {}, 'mblen() works on UTF-8 characters');