'我' takes 2 bytes  '\0' takes 1 byte , so "我“ takes 3

Every chinese charecter takes 2 bytes
  ----- Original Message ----- 
  From: Neil 
  To: beginners@perl.org 
  Sent: Wednesday, May 16, 2007 1:57 PM
  Subject: Chinese word problem


  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 

   



------------------------------------------------------------------------------


  -- 
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  http://learn.perl.org/

Reply via email to