1BEGIN { 2 if ($ENV{'PERL_CORE'}){ 3 chdir 't'; 4 unshift @INC, '../lib'; 5 } 6 require Config; import Config; 7 if ($Config{'extensions'} !~ /\bEncode\b/) { 8 print "1..0 # Skip: Encode was not built\n"; 9 exit 0; 10 } 11 $| = 1; 12} 13 14use strict; 15use Test::More tests => 21; 16use Encode; 17 18# The specification of GSM 03.38 is not awfully clear. 19# (http://www.unicode.org/Public/MAPPINGS/ETSI/GSM0338.TXT) 20# The various combinations of 0x00 and 0x1B as leading bytes 21# are unclear, as is the semantics of those bytes as standalone 22# or as final single bytes. 23 24sub t { is(decode("gsm0338", my $t = $_[0]), $_[1]) } 25 26# t("\x00", "\x00"); # ??? 27 28# "Round-trip". 29t("\x41", "\x41"); 30 31t("\x01", "\xA3"); 32t("\x02", "\x24"); 33t("\x03", "\xA5"); 34t("\x09", "\xE7"); 35 36t("\x00\x00", "\x00\x00"); # Maybe? 37t("\x00\x1B", "\x40\xA0"); # Maybe? 38t("\x00\x41", "\x40\x41"); 39 40# t("\x1B", "\x1B"); # ??? 41 42# Escape with no special second byte is just a NBSP. 43t("\x1B\x41", "\xA0\x41"); 44 45t("\x1B\x00", "\xA0\x40"); # Maybe? 46 47# Special escape characters. 48t("\x1B\x0A", "\x0C"); 49t("\x1B\x14", "\x5E"); 50t("\x1B\x28", "\x7B"); 51t("\x1B\x29", "\x7D"); 52t("\x1B\x2F", "\x5C"); 53t("\x1B\x3C", "\x5B"); 54t("\x1B\x3D", "\x7E"); 55t("\x1B\x3E", "\x5D"); 56t("\x1B\x40", "\x7C"); 57t("\x1B\x40", "\x7C"); 58t("\x1B\x65", "\x{20AC}"); 59 60 61 62 63