Posted on 2005-02-15 09:41:00-08 by dirk
Space character dropped in MARC::Charset::_unpack
The space character is dropped in the conversions to_utf8 and to_marc8. This happens because of the way the _unpack function is implemented. It uses pack/unpack pattern "A3" which removes trailing spaces. But if the packed string starts with three spaces, all three spaces are removed.
Here is one possible way to fix the problem:
sub _unpack { my $x = shift; return( undef ) if ! defined( $x ); # return ( unpack( 'A3A1A1', $x ) ); # added: my ($s1, $s2, $s3) = unpack( 'A3A1A1', $x ); $s1 =~ s/^$/ /; return ($s1, $s2, $s3); }
Dirk Kinnaes K.U.Leuven LIBIS-Net
Direct Responses: 118 | 119 | Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.