Adding new encodings to perl XML::Parser

Some Cyrillic encodings (windows-1251, cp866, koi8-r) can be located at http://uucode.com/xml/perl/. XML::Parser modules has a limited set of internal encodings, so in case you need something exotic, you need to download XML::Encoding library and run the following script (or do it step by step):

#!/bin/sh
 
XML_PACKAGE=XML-Encoding-2.07
 
if [ -z "$1" -o -z "$2" ]
then
    echo "Usage: $0 [ftp-path] [encoding]"
    echo "$0 ISO8859/8859-15.TXT iso-8859-15"
    echo "$0 VENDORS/MICSFT/WINDOWS/CP1251.TXT windows-1251"
    exit
fi
 
[ ! -f `basename $1` ] && wget -nv "ftp://ftp.unicode.org/Public/MAPPINGS/$1"
 
mkdir XML 2> /dev/null
 
tar -xzOf $XML_PACKAGE.tar.gz $XML_PACKAGE/Encoding.pm > XML/Encoding.pm
tar -xzOf $XML_PACKAGE.tar.gz $XML_PACKAGE/bin/make_encmap > make_encmap
tar -xzOf $XML_PACKAGE.tar.gz $XML_PACKAGE/bin/compile_encoding > compile_encoding
 
perl ./make_encmap "$2" `basename $1` | perl -pe "s/^(<encmap)/\$1 expat='yes'/" > "$2.encmap"
perl ./compile_encoding -o "$2.enc" "$2.encmap"
 
rm -R XML make_encmap compile_encoding "$2.encmap"
programming/perl/xml_parser_encoding.txt · Last modified: 2009/05/18 00:16 by dmitry
 
 
Recent changes RSS feed Driven by DokuWiki