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