OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Parsing XML with special characters (Perl XML::Parser)

[ Lists Home | Date Index | Thread Index ]

Carlos Prim wrote:

>Hello.
>
>I'm trying to parse some remote XML files, but they include
>Spanish special characters. I work on Linux, with Perl and
>'XML::Parser' module (downloaded from CPAN).
>
>But I have some problems with the characters, as I get 
>'año' instead of 'año', or 'práctico' instead of
>'práctico'.
>
>I tried with 'Text::Iconv' and 'Unicode::MapUTF8' Perl 
>modules, but -I don't know if I do it wrong- it does not
>work
>correctly (texts do not change).
>
>I do not know if I should install another module on my Linux
>machine, or if it works really with 'Unicode::MapUTF8'.
>
>Does anybody have any experience? Thank you very much.
>  
>
The first thing to check is whether the XML files have the correct
encoding header. If the files are in UTF-8, as it seems, they should have
something like
<?xml version="1.0" encoding="UTF-8"?>

A decent XML parser should recognise this header and set itself for the
correct encoding.

The second thing to check is whether your system can display UTF-8
text. If you are using a Unix-ish system, chances are that if you
print a file or read it into a text editor, it will read using the default
character set for your system. Thus you will see strange characters
on screen, even though your data is correct. The solution there
is to use a correct Unicode-aware editor or viewer.

As for Perl libraries, I leave that to a Perl expert.

Cheers
Rick Jelliffe






 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS