in reply to Re^5: Perl Modules for handling Non English text
in thread Perl Modules for handling Non English text

The original question was how to handle Hindi and the answer is that Perl does fine and "C" does fine with that as this only requires 16 bits.

That's wrong. Perl can do Hindi because Perl can do Unicode. The number of bits has nothing to do with it. There are 8-bit characters Perl cannot handle, for example, because the characters from that character set aren't in Unicode.

And you're wrong about Hindi characters requiring 16 bits. It depends on the encoding.

  • Comment on Re^6: Perl Modules for handling Non English text

Replies are listed 'Best First'.
Re^7: Perl Modules for handling Non English text
by Marshall (Canon) on Mar 31, 2009 at 05:08 UTC
    Hindi encodes into something that both C and Perl can understand and is <= 16 bits. I will talk with a friend of mine who is a native speaker and get back to you. But I am very confident about this. Full representation of oriental languages can take more bits... no question at all!

      Perl uses iso-8859-1 and UTF-8, so
      Characters U+000000 to U+00007F take one byte.
      Characters U+000080 to U+0000FF take one (iso-8859-1) or two (UTF-8) bytes.
      Characters U+000100 to U+0007FF take two bytes.
      Characters U+000800 to U+00FFFF take three bytes.
      Characters U+010000 to U+10FFFF take four bytes.

      Wikipedia indicates Hindi uses Devanagari script (U+000900..U+00097F). All indic scripts are above U+000900.

      use Encode qw( _utf8_off ); my $x = chr(0x900); _utf8_off( $x ); # Get internal representation. print(length($x), "\n"); # 3
        Your hex math looks fine. I am just saying that Hindi, like most languages can be described with <= 16 bits per character. Languages like Chinese or Japanese are more complex.

        As to how these languages can be expressed as a sequence of more simple things....think about Morse Code...there are a limited number of symbols that can be generated and understood. I do not doubt your book, but I do doubt the practice.

        I'm sure there are some Europeans and Asians who can speak better on this topic than I can.