From: Anton Bangratz Date: 2008-10-01T15:07:22+09:00 Subject: Re: How to emit UTF-8 from console mode program? --------------enigDCC7BF74C8E77B7C8804FB04 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Siegfried Heintze wrote: > The following perl program works when I run it from urxvt-X console on > cygwin-x windows when running on Microsoft Windows XP: >=20 > LC_CTYPE=3Den_US.UTF-8 urxvt-X.exe& > perl -wle "binmode STDOUT, q[:utf8]; print chr() for 0x410 .. 0x430;" >=20 > This little one liner prints the Russian alphabet in Cryllic. With some= > slight modification it will also print a lot of other alphabets too -- > including Hebrew, chinese and japanese. >=20 > It does not work with cmd.exe because apparently cmd.exe cannot deal wi= th > UTF-8. >=20 > Can someone help me translate it into ruby? I would not expect it to wo= rk > from cmd.exe with ruby, but I am hopeful it will work with urxvt-X! >=20 > Thanks, > Siegfried >=20 >=20 >=20 >=20 >=20 Quick and dirty (works in Linux xterm -u, ruby 1.8.7): ruby -Ku -e "(0x410...0x430).each {|x| puts [x].pack('U')}" The -K option is 'u' for setting the encoding to unicode, same as setting '$KCODE=3D"u"' at the beginning of the code. Array#pack is used because for Integer.chr, 1040ff are out of range. Hope this helps, t. --=20 Anton Bangratz - Key ID 363474D1 - http://tony.twincode.net/ fortune(6): Yow! It's a hole all the way to downtown Burbank! --------------enigDCC7BF74C8E77B7C8804FB04 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iQEcBAEBAgAGBQJI4xPTAAoJEAgZMsE2NHTRD/IH/RyBdhNqBdc5Nxnj3NLvBMKR ff+2XE8mkMqfV1IvXgtG5Gi0EAfDXm+hEjjZHqIJoCP5r3hcUql4QSLDAHKQfQd8 pVvRMQOXUq8oBFvGaAfE4HCdYqfNpb8F3HeTlnZ6OFwzs2QNxGZg/DPEkabx5jYa 4eoBgkPInkaVBxKumg4JDKu6/jER0YmpkfoqtJoanMDl38Kc7JqsqGO3HzXF/88A y4SoX3nnIwBwO6WcO0JGqnWFjhaIw6scp57C7nfXk1AGxwd3AVAVejpFjOKERDWH k1TG6DO9uTCTiEyfBLXEY21LcgTqKm/DpbVWwP+A2vXu8kCkT4KU/3NPcbqHZcA= =/IA4 -----END PGP SIGNATURE----- --------------enigDCC7BF74C8E77B7C8804FB04--