>You are getting diverted by how perl happens internally to store a string.
>This is almost always completely irrelevant

This would be the case perhaps, but for fairly inconsistent and buggy support for UTF8 in Perl; I've found that there are enough problems where things "Just Don't Work" (tm) that one is quickly forced to start debugging at a pretty low level when writing any kind of non-trivial UTF8 code in Perl.

At the moment, I'm trying to figure out why I can't transfer UTF-8 encoded XML across a data path that involves LWP, CGI.pm, and application/x-www-form-urlencoded form data. There's really no way to debug this without digging into the precise data formats that one can grab at various points in the system.

(And apart from that, the Perl docs make it very clear that the internals are UTF8, so it's fairly difficult to ignore it.)

>$str above is a perl string that contains one character,
>and ord(that_character) is 0x39a.

That we agree upon.

>Whether perl happens to remember that fact by storing the
>two bytes 0xCE and 0x9A somewhere in memory shouldn't normally concern you.

It *shouldn't* concern me, but I seem to have to worry this stuff rather more often than I'd like.

>I don't understand what you are trying to say there.

I was pointing out that your claim that the strings in your example code are different doesn't make sense to me; if you use, say, unpack("H*", ..) to dump out the contents of the string both before and after encode_utf8, you find that they are byte-for-byte identical.

You showed some code that merely demonstrated that the length function was interpreting the contents either as characters or bytes (presumably because one has the utf8 flag on and the other doesn't).


In reply to Re^6: What does Encode::encode_utf8 do to UTF-8 data ? by scollyer
in thread What does Encode::encode_utf8 do to UTF-8 data ? by scollyer

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, details, 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, summary, 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.