Changeset 4791
- Timestamp:
- 2003-06-25T09:44:33+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/MARCPlug.pm
r4785 r4791 159 159 160 160 161 # The bulk of this function is based on read_line in multiread.pm 162 # Unable to use read_line original because it expects to get its input 163 # from a file. Here the line to be converted is passed in as a string 164 165 sub to_utf8 166 { 167 my $self = shift (@_); 168 my ($encoding, $line) = @_; 169 170 if ($encoding eq "iso_8859_1") { 171 # we'll use ascii2utf8() for this as it's faster than going 172 # through convert2unicode() 173 return &unicode::ascii2utf8 (\$line); 174 } 175 176 # everything else uses unicode::convert2unicode 177 return &unicode::unicode2utf8 (&unicode::convert2unicode ($encoding, \$line)); 178 } 179 180 161 181 sub read_file { 162 182 my $self = shift (@_); 163 183 my ($filename, $encoding, $language, $textref) = @_; 184 185 $self->{'readfile_encoding'} = $encoding; 164 186 165 187 @marc_entries = (); … … 214 236 $$textref =~ s/>/>/g; 215 237 238 my $encoding = $self->{'readfile_encoding'}; 239 $$textref = $self->to_utf8($encoding,$$textref); 240 216 241 print $outhandle " Adding Marc Record:\n",substr($$textref,0,40), " ...\n" 217 242 if $self->{'verbosity'} > 2; … … 231 256 my ($marc, $metadata, $doc_obj, $section) = @_; 232 257 my $outhandle = $self->{'outhandle'}; 258 259 my $encoding = $self->{'readfile_encoding'}; 233 260 234 261 my $metadata_mapping = $self->{'metadata_mapping'}; … … 245 272 foreach $metavalue ( @metavalues ) 246 273 { 247 $doc_obj->add_utf8_metadata ($thissection, $metaname, $metavalue->as_string()); 274 $metavalue_str = $self->to_utf8($encoding,$metavalue->as_string()); 275 $doc_obj->add_utf8_metadata ($thissection, $metaname, $metavalue_str); 248 276 } 249 277 }
Note:
See TracChangeset
for help on using the changeset viewer.