Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Annoying, isn't it? Perl has its own idea of whether your data should be treated as UTF8 or as 8-bit encoding, and it may not agree with your idea. If you concat a plain 8-bit string with a string marked as UTF-8, Perl will convert the 8-bit string to UTF-8 as well, whether you want it or not.

The trickery is all connected to the UTF8 flag, which is a bit flag attached to each string. For the data that XML::Parser returns, that UTF8 flag is set.

To get rid of this behaviour, clear the UTF8 flag. One way you can do it, is like this:

sub de_utf8 { use bytes; return "$_[0]"; }
This way, the resulting string will be the same byte data as the original string, but with the UTF8 flag cleared. So now, the string should stay in ISO-Latin-1.

In reply to Re: XML::Parser Encoding (UTF-8 -> ISO-8859-1) by bart
in thread XML::Parser Encoding (UTF-8 -> ISO-8859-1) by Emanuel

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2023-04-01 14:39 GMT
Find Nodes?
    Voting Booth?

    No recent polls found