Changeset 73 for trunk/gsdl/perllib/doc.pm
- Timestamp:
- 1998-12-11T20:59:16+13:00 (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r65 r73 3 3 package doc; 4 4 5 use unicode; 5 6 use util; 6 7 use html; … … 463 464 # are for metadata which can have more than one value. 464 465 466 # set_metadata_element assumes the value is in (extended) ascii form. 467 # For text which hash been already converted to the UTF-8 format use 468 # set_utf8_metadata_element. 465 469 sub set_metadata_element { 466 470 my $self = shift (@_); 467 471 my ($section, $field, $value) = @_; 468 472 473 $self->set_utf8_metadata_element ($section, $field, 474 &unicode::ascii2utf8($value)); 475 } 476 477 # set_utf8_metadata_element assumes the text has already been 478 # converted to the UTF-8 encoding. 479 sub set_utf8_metadata_element { 480 my $self = shift (@_); 481 my ($section, $field, $value) = @_; 482 469 483 $self->delete_metadata ($section, $field); 470 $self->add_ metadata ($section, $field, $value);484 $self->add_utf8_metadata ($section, $field, $value); 471 485 } 472 486 … … 491 505 } 492 506 507 # add_metadata assumes the text is in (extended) ascii form. For 508 # text which hash been already converted to the UTF-8 format use 509 # add_utf8_metadata. 493 510 sub add_metadata { 494 511 my $self = shift (@_); 495 512 my ($section, $field, $value) = @_; 496 513 497 my $section_ptr = $self->_lookup_section($section); 498 if (!defined $section_ptr) { 499 print STDERR "doc::add_metadata couldn't find section " . 514 $self->add_utf8_metadata ($section, $field, 515 &unicode::ascii2utf8($value)); 516 } 517 518 # add_utf8_metadata assumes the text has already been converted 519 # to the UTF-8 encoding. 520 sub add_utf8_metadata { 521 my $self = shift (@_); 522 my ($section, $field, $value) = @_; 523 524 my $section_ptr = $self->_lookup_section($section); 525 if (!defined $section_ptr) { 526 print STDERR "doc::add_utf8_metadata couldn't find section " . 500 527 "$section\n"; 501 528 return; … … 618 645 # methods for dealing with text 619 646 647 # add_text assumes the text is in (extended) ascii form. For 648 # text which has been already converted to the UTF-8 format 649 # use add_utf8_text. 620 650 sub add_text { 621 651 my $self = shift (@_); 622 652 my ($section, $text) = @_; 623 653 624 my $section_ptr = $self->_lookup_section($section); 625 if (!defined $section_ptr) { 626 print STDERR "doc::add_text couldn't find section " . 654 # convert the text to UTF-8 encoded unicode characters 655 # and add the text 656 $self->add_utf8_text($section, &unicode::ascii2utf8($text)); 657 } 658 659 660 # add_utf8_text assumes the text to be added has already 661 # been converted to the UTF-8 encoding. For ascii text use 662 # add_text 663 sub add_utf8_text { 664 my $self = shift (@_); 665 my ($section, $text) = @_; 666 667 my $section_ptr = $self->_lookup_section($section); 668 if (!defined $section_ptr) { 669 print STDERR "doc::add_utf8_text couldn't find section " . 627 670 "$section\n"; 628 671 return; … … 647 690 } 648 691 649 # returns the length of the text for a section692 # returns the (utf-8 encoded) length of the text for a section 650 693 sub get_text_length { 651 694 my $self = shift (@_);
Note:
See TracChangeset
for help on using the changeset viewer.