Neil wrote:
>
> Dear All:
>
> Question:
>
> How come the length of Chinese word I print shows “ 3 “.
>
> Isn’t it supposed to 2 bytes?
>
> Program:
>
> -----------------------------------
>
> $str=”我”;
>
> $str_len = length($str);
>
> Print $str_len, “\n\n”;
>
> ------------------------------------
>
> The result is 3
>
> I took a picture for the program. In case of it doesn’t show Chinese
> word in some of your system,
>
> Pls see the attachment
>
> My environment:
>
> CPU: Intel Pentium C2D T7200
>
> OS: Fedora Core 6
>
> Perl V: 5.8.8
>
> Encode: Big5
>
> Thank you
>
First, "我" is comes with 2 bytes ASCII 167 + 218 in BIG5 coding. What I
would bet the
guess is the editor converted something before you run the code or
because you are on
a *nix platform ( since you heading your script #!/usr/bin/perl , so I
assume ) , however I
don't familiar with.

You may check if there's some Unicode or UTF-8 issues. in UTF-8, there's
3 bytes.
You may also check for other words and see if there's still in 3 bytes.

HTH,
Mug



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply via email to