The MARC::Charset function to_marc8 drops all space
characters. This happens because of the way the
_unpack function is implemented. It uses pack/unpack
format "A" 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 );
# removed: return ( unpack( 'A3A1A1', $x ) );
# added:
my ($s1, $s2, $s3) = unpack( 'A3A1A1', $x );
$s1 =~ s/^$/ /;
return ($s1, $s2, $s3);
}
Cleaning up old bugs; this one became moot with commit a607c5ae that overhauled MARC::Charset.