Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: XML::Simple parser error : Input is not proper UTF-8, indicate encoding

by daxim (Curate)
on Aug 10, 2012 at 13:32 UTC ( [id://986746]=note: print w/replies, xml ) Need Help??


in reply to XML::Simple parser error : Input is not proper UTF-8, indicate encoding

XML is not a container format for just any data. You can only put certain characters in it!

I assume that in your weird notation

<CALLERID><A0>jW<B7>h<AE><F5><BF><8A>7a<B7><D8>T<D9>^N</CALLER +ID>

A0 etc in angles is equivalent to \xA0 in Perl, and ^N is equivalent to \cN in Perl. That last character (chr(14) == #x0E == U+000E) is illegal in XML.

You must encode binary data for XML, Base64 is a common choice.

  • Comment on Re: XML::Simple parser error : Input is not proper UTF-8, indicate encoding
  • Download Code

Replies are listed 'Best First'.
Re^2: XML::Simple parser error : Input is not proper UTF-8, indicate encoding
by nvivek (Vicar) on Aug 17, 2012 at 05:31 UTC
    I solved the problem by replacing non-printable characters to nil, before writing to XML file. My regular expression is as follows.
    # following is a code to remove non-printable characters in string i +ncluding newline s/[^[:print:]]+//g; # this pattern won't remove newline char s/([\x00-\x09]+)|([\x0B-\x1F]+)//g;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://986746]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2024-04-19 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found