Now this is getting interesting :-), when I ran my code, I got this: (I am using AS 5.8.0, and the testing code for case 4 is at the end of this post).

=========================
Case 1: create string from pack, with use bytes

char semantics: ƐIJ Length = 2, Content = 400.306
byte semantics: ƐIJ Length = 4, Content = 198.144.196.178
198.144.196.178
=========================
Case 2: create string from pack, with use buyes

char semantics: ƐIJ Length = 2, Content = 400.306
byte semantics: ƐIJ Length = 4, Content = 198.144.196.178
400.306
=========================
Case 3: create string from \x{}

char semantics: ƐIJ Length = 2, Content = 400.306
byte semantics: ƐIJ Length = 4, Content = 198.144.196.178
400.306
=========================
Case 4: read string from unicode file

char semantics: 裴佳谷
 Length = 4, Content = 35060.20339.35895.10
byte semantics: 裴佳谷
 Length = 10, Content = 232.163.180.228.189.179.232.176.183.10
Also, I want to add a case to cover the situation where you read your string from file:
{ print "=========================\n"; print "Case 4: read string from utf8 file\n"; open(FILE, "<:utf8", "test.txt"); $encoded_string = <FILE>; display $encoded_string; }

In reply to Re: Re: Re: use bytes and length problem by pg
in thread use bytes and length problem by muad33b

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.