1# Helper for some of the .t's in this directory
2
3sub native_to_uni($) {  # Convert from platform character set to Unicode
4                        # (which is the same as ASCII)
5    my $string = shift;
6
7    return $string if ord("A") == 65
8                      || $] lt 5.007_003; # Doesn't work on early EBCDIC Perls
9    my $output = "";
10    for my $i (0 .. length($string) - 1) {
11        $output .= chr(utf8::native_to_unicode(ord(substr($string, $i, 1))));
12    }
13    # Preserve utf8ness of input onto the output, even if it didn't need to be
14    # utf8
15    utf8::upgrade($output) if utf8::is_utf8($string);
16
17    return $output;
18}
19
20
21sub ascii_order {   # Sort helper.  Causes the order to be the same as ASCII
22                    # no matter what the platform's character set is.
23    return native_to_uni($a) cmp native_to_uni($b);
24}
25
261
27