--- nfo/perl/libs/Data/Mungle/Transform/Encode.pm 2003/04/09 07:22:34 1.5 +++ nfo/perl/libs/Data/Mungle/Transform/Encode.pm 2003/05/13 07:42:59 1.6 @@ -1,7 +1,10 @@ ## ------------------------------------------------------------------------- -## $Id: Encode.pm,v 1.5 2003/04/09 07:22:34 joko Exp $ +## $Id: Encode.pm,v 1.6 2003/05/13 07:42:59 joko Exp $ ## ------------------------------------------------------------------------- ## $Log: Encode.pm,v $ +## Revision 1.6 2003/05/13 07:42:59 joko +## + sub decode_hex_nybbles: e.g. required to decode binary data from cellular phones +## ## Revision 1.5 2003/04/09 07:22:34 joko ## childObj2string now inside Encode.pm, renamed to 'twingle_reference' ## @@ -36,6 +39,7 @@ &utf8_to_latin &utf8_to_latin_scalar &twingle_reference + &decode_hex_nybbles ); @@ -126,6 +130,16 @@ return $string; } +sub decode_hex_nybbles { + my $data = shift; + my @buf; + for (my $i = 0; $i <= length($data); $i = $i + 2) { + my $nybble = substr($data, $i, 2); + push @buf, chr(hex($nybble)); + } + return join('', @buf); +} + 1; __END__