Changeset 4229


Ignore:
Timestamp:
2003-05-06T15:46:31+12:00 (21 years ago)
Author:
mdewsnip
Message:

Replaced unicode2koi8r with a more generic version: unicode2singlebyte. This can be used to convert unicode to any single byte encoding - (KOI8-R, the Kazakh encoding, etc.).

File:
1 edited

Legend:

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

    r3834 r4229  
    230230#
    231231# Examples of encodings that may be converted using singlebyte2unicode are
    232 # the iso-8859 and windows-125* series).
     232# the iso-8859 and windows-125* series.
    233233sub singlebyte2unicode {
    234234    my ($encodename, $textref) = @_;
     
    385385# @array256 is used for initialisation, there must be
    386386# a better way...
     387# What about this?: @array256 = (0) x 256;
    387388@array256 = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
    388389         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
     
    429430}
    430431
    431 sub unicode2koi8r {
    432     my ($uniref) = @_;
    433    
     432# unicode2singlebyte converts unicode to simple 8 bit encodings where
     433# characters below 0x80 are normal ascii characters and the rest are encoded
     434# using the appropriate mapping files.
     435#
     436# Examples of encodings that may be converted using unicode2singlebyte are
     437# the iso-8859 and windows-125* series, KOI8-R (Russian), and the Kazakh encoding.
     438sub unicode2singlebyte {
     439    my ($uniref, $encoding) = @_;
     440
    434441    my $outtext = "";
    435     my $encodename = "unicode-koi8_r";
    436     my $enc_info = $encodings::encodings->{"koi8_r"};
     442    my $encodename = "unicode-$encoding";
     443    my $enc_info = $encodings::encodings->{"$encoding"};
    437444    my $mapfile = &util::filename_cat($ENV{'GSDLHOME'}, "mappings",
    438445                      "from_uc", $enc_info->{'mapfile'});
Note: See TracChangeset for help on using the changeset viewer.