diff options
author | Karl Williamson <public@khwilliamson.com> | 2013-05-20 22:20:29 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2015-01-19 16:36:40 -0700 |
commit | 9de25f670cff2971801ead2abf4fa319eb086936 (patch) | |
tree | 6a652287a9a0e925fcdfd942eec6088ffbff1c06 | |
parent | f63bc603acea5e0f476f181de698958c4ddcccba (diff) | |
download | perl-9de25f670cff2971801ead2abf4fa319eb086936.tar.gz |
lib/locale.t: Generalize to work on non-ASCII
-rw-r--r-- | lib/locale.t | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/locale.t b/lib/locale.t index 8a3d44bc1d..1c25704147 100644 --- a/lib/locale.t +++ b/lib/locale.t @@ -7,6 +7,8 @@ # To make a TODO test, add the string 'TODO' to its %test_names value +my $is_ebcdic = ord("A") == 193; + binmode STDOUT, ':utf8'; binmode STDERR, ':utf8'; @@ -2366,13 +2368,18 @@ setlocale(&POSIX::LC_ALL, "C"); # All casing operations under locale (but not :not_characters) should # taint if ($function =~ /^u/) { - @list = ("", "a", "\xe0", "\xff", "\x{fb00}", "\x{149}", "\x{101}"); - $ascii_case_change_delta = -32; + @list = ("", "a", + chr(utf8::unicode_to_native(0xe0)), + chr(utf8::unicode_to_native(0xff)), + "\x{fb00}", "\x{149}", "\x{101}"); + $ascii_case_change_delta = ($is_ebcdic) ? +64 : -32; $above_latin1_case_change_delta = -1; } else { - @list = ("", "A", "\xC0", "\x{17F}", "\x{100}"); - $ascii_case_change_delta = +32; + @list = ("", "A", + chr(utf8::unicode_to_native(0xC0)), + "\x{17F}", "\x{100}"); + $ascii_case_change_delta = ($is_ebcdic) ? -64 : +32; $above_latin1_case_change_delta = +1; } foreach my $is_utf8_locale (0 .. 1) { @@ -2386,9 +2393,9 @@ setlocale(&POSIX::LC_ALL, "C"); no warnings 'locale'; $should_be = ($j == $#list) ? chr(ord($char) + $above_latin1_case_change_delta) - : (length $char == 0 || ord($char) > 127) - ? $char - : chr(ord($char) + $ascii_case_change_delta); + : (length $char == 0 || utf8::native_to_unicode(ord($char)) > 127) + ? $char + : chr(ord($char) + $ascii_case_change_delta); # This monstrosity is in order to avoid using an eval, # which might perturb the results |