The reason that print chr(0x141); and print chr(321); print the same thing is because 321 in decimal is equivalent to 141 in hex. The statement print "\x{141}"; gives me an Illegal hex digit ignored... when I use the -w switch and simply prints {141}.
Typically, with Standard ASCII, there are no characters above 128 decimal (or 256 if using Extended ASCII). When you attempt to print chr(321);, Perl simply drops the bits that are irrelevant and prints an "A", which is 65 in ASCII (256+65=321).
Since Japanese characters (and Unicode) are represented by two bytes instead of one, perhaps what is happening is you have some weird buffering problem where an extra byte gets moved to STDOUT, thereby throwing off the bytes that follow. Typically, Perl buffers output to STDOUT so you get things printed only after enough "stuff" is in STDOUT. This is a performance improvement, but can cause problems if things are being written to STDOUT slowly or unusually. Try undefining $|, which causes an autoflush on output, and seeing what you get. Maybe you'll autoflush an errant byte?
Cheers,
Ovid
In reply to (Ovid) Re: Unicode on Win2k
by Ovid
in thread Unicode on Win2k
by Mike McClellan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |