Changeset 1223


Ignore:
Timestamp:
2000-06-21T10:24:15+12:00 (24 years ago)
Author:
sjboddie
Message:

added an arabic2unicode conversion function to unicode.pm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/unicode.pm

    r537 r1223  
    3333
    3434
    35 # ascii2unicode takes a (extended) ascii string and
    36 # returns a unicode array.
     35# ascii2unicode takes an (extended) ascii string (ISO-8859-1)
     36# and returns a unicode array.
    3737sub ascii2unicode {
    3838    my ($in) = @_;
     
    4949}
    5050
     51# arabic2unicode takes an 8 bit Arabic string (ISO-8859-6)
     52# and returns a unicode array
     53sub arabic2unicode {
     54    my ($in) = @_;
     55    my $out = [];
     56
     57    my $i = 0;
     58    my $len = length($in);
     59    while ($i < $len) {
     60    my $c = ord(substr ($in, $i, 1));
     61    $c += (1567-191) if ($c >= 0x80);
     62    push (@$out, $c);
     63    $i++;
     64    }
     65
     66    return $out;
     67}
    5168
    5269# ascii2utf8 takes a (extended) ascii string and
Note: See TracChangeset for help on using the changeset viewer.