File: translate.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (26 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!./perl

# Verify round trip of translations from the native character set to unicode
# and back work.  If this is wrong, nothing will be reliable.

print "1..257\n";   # 0-255 plus one beyond

for my $i (0 .. 255) {
    my $uni = utf8::native_to_unicode($i);
    if ($uni < 0 || $uni >= 256) {
        print "not ";
    }
    elsif (utf8::unicode_to_native(utf8::native_to_unicode($i)) != $i) {
        print "not ";
    }
    print "ok ";
    print $i + 1 . " - native_to_unicode $i";
    print "\n";
}

# Choose a largish number that might cause a seg fault if inappropriate array
# lookup
if (utf8::unicode_to_native(utf8::native_to_unicode(100000)) != 100000) {
    print "not ";
}
print "ok 257 - native_to_unicode of large number\n";