Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Description

The XML::UM module uses the maps that come with XML::Encoding to perform the reverse operation. It creates mapping routines that encode a UTF-8 string in the chosen encoding.

This module comes in handy when processing XML, as XML::Parser converts all strings to UTF-8.

A typical usage scenario would be:

# create the encoding routine (only once!) $encode= XML::UM::get_encode(Encoding => 'big5'); ... # convert a utf8 string to the desired encoding $encoded_string= $encode($utf8_string);

Warning: the version of XML::UM in libxml-enno-1.02 has an installation problem. To fix this, once you have downloaded and uncompressed the module, before doing perl Makefile.PL, edit the XML::UM.pm file in the lib/XML directory and replace the $ENCDIR value with the location of your XML::Encoding maps (it should be /usr/local/src/XML-Encoding-1.01/maps or /opt/src/XML-Encoding-1.01/maps/).

Why use XML::UM?

  • it works!
  • it might be the only easy solution for you

Why NOT use XML::UM?

  • it's slow
  • it cannot deal with latin-1
  • you can wait for the new Unicode features in Perl

Personal comments

XML::UM is probably just an interim solution while the new Unicode features in Perl are being developed. They will essentially perform the same tasks, just faster and in the Perl core (which means more support)

In the meantime XML::UM is easy to use and can really save you some headaches with encodings.

The absence of latin-1 conversion function (due to the fact that expat supports latin-1 natively, hence there is no encoding table for it in XML:Encoding) is a big flaw though.

It would be real nice if someone would pick up the module and add latin1. Recoding it in C could help too.


In reply to XML::UM by mirod

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chilling in the Monastery: (5)
    As of 2020-05-25 09:32 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      If programming languages were movie genres, Perl would be:















      Results (145 votes). Check out past polls.

      Notices?