Ignore:
Timestamp:
2011-06-22T18:31:37+12:00 (13 years ago)
Author:
ak19
Message:

Non-English characters in the user-entered buttonname of all classifiers need to be preserved. BaseClassifier now does this, for which it has to assume that the user-entered buttonname is in UTF-8

Location:
main/trunk/greenstone2/perllib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/classify/BaseClassifier.pm

    r23116 r24193  
    5656use printusage;
    5757use parse2;
     58use unicode;
    5859
    5960# suppress the annoying "subroutine redefined" warning that various
     
    278279   
    279280    delete $self->{"info_only"};
     281    # user-entered UTF-8 display meta for buttonname. Needs to be internally turned into unicode
     282    # (will later be turned back to UTF-8 along with the rest of the metadata)
     283    if ($self->{'buttonname'}) {
     284        $self->{'buttonname'} = &unicode::convert_utf8_string_to_unicode_string($self->{'buttonname'});
     285    }
    280286    return bless $self, $class;
    281287}
     
    369375}
    370376
     377
    371378# ex. can be at front, or it may be a list of metadata, separated by ,/;
    372379sub strip_ex_from_metadata {
  • main/trunk/greenstone2/perllib/classify/List.pm

    r24147 r24193  
    680680
    681681
    682 sub convert_utf8_string_to_unicode_string
    683 {
    684     my $self = shift(@_);
    685     my $utf8_string = shift(@_);
    686 
    687     my $unicode_string = "";
    688     foreach my $unicode_value (@{&unicode::utf82unicode($utf8_string)}) {
    689     $unicode_string .= chr($unicode_value);
    690     }
    691     return $unicode_string;
    692 }
    693 
    694 
    695 sub convert_unicode_string_to_utf8_string
    696 {
    697     my $self = shift(@_);
    698     my $unicode_string = shift(@_);
    699 
    700     my @unicode_array;
    701     for (my $i = 0; $i < length($unicode_string); $i++) {
    702     push(@unicode_array, ord(substr($unicode_string, $i, 1)));
    703     }
    704     return &unicode::unicode2utf8(\@unicode_array);
    705 }
    706 
    707 
    708682sub generate_partition_start
    709683{
  • main/trunk/greenstone2/perllib/unicode.pm

    r23831 r24193  
    848848
    849849
     850sub convert_utf8_string_to_unicode_string
     851{
     852    my $utf8_string = shift(@_);
     853
     854    my $unicode_string = "";
     855    foreach my $unicode_value (@{&unicode::utf82unicode($utf8_string)}) {
     856    $unicode_string .= chr($unicode_value);
     857    }
     858    return $unicode_string;
     859}
     860
     861sub convert_unicode_string_to_utf8_string
     862{
     863    my $unicode_string = shift(@_);
     864
     865    my @unicode_array;
     866    for (my $i = 0; $i < length($unicode_string); $i++) {
     867    push(@unicode_array, ord(&substr($unicode_string, $i, 1)));
     868    }
     869    return &unicode::unicode2utf8(\@unicode_array);
     870}
     871
     872
    8508731;
Note: See TracChangeset for help on using the changeset viewer.