devnul has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I am trying to work with a XML document and having some encoding-type issues with it.
First, this is the first few bytes of the XML document passed through "od -c":
.. I think I must be missing something obvious here...
- dEvNuL
Of relevance here, I suppose, is that it is encoding="utf-16", which appears to me the XML document is correctly formed, although I am certainly no expert in this area. In plain ASCII, this would look something like:0000000 377 376 < \0 ? \0 x \0 m \0 l \0 \0 v \ +0 0000020 e \0 r \0 s \0 i \0 o \0 n \0 = \0 " \ +0 0000040 1 \0 . \0 0 \0 " \0 \0 e \0 n \0 c \ +0 0000060 o \0 d \0 i \0 n \0 g \0 = \0 " \0 u \ +0 0000100 t \0 f \0 - \0 1 \0 6 \0 " \0 ? \0 > \ +0 0000120 \r \0 \n \0 < \0 l \0 i \0 s \0 t \0 i \ +0 0000140 n \0 g \0 _ \0 f \0 e \0 e \0 d \0 > \ +0 0000160 \r \0 \n
Now, I'm trying to do a regular expression match on this string, like so:<?xml version="1.0" encoding="utf-16"?> <listing_feed>
.. but this does not work... However, this does:if($string =~ m/xml/) { ... }
Have I completely misunderstood that this type of regular expression match should work? I've tried using the "Encode" module to re-code this to UTF-8, or even ASCII but nothing I do can make this work.if($string =~ m/x.m.l./) { ... }
.. I think I must be missing something obvious here...
- dEvNuL
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Encoding question
by ikegami (Patriarch) on Nov 07, 2006 at 01:08 UTC | |
Re: Encoding question
by Errto (Vicar) on Nov 07, 2006 at 01:22 UTC | |
Re: Encoding question
by graff (Chancellor) on Nov 07, 2006 at 02:42 UTC |
Back to
Seekers of Perl Wisdom