From: Nobuyoshi Nakada Date: 2002-07-08T02:12:14+09:00 Subject: Re: is there a better string.each? Hi, At Sun, 7 Jul 2002 22:43:57 +0900, Dossy wrote: > > 'foo'.split '' > > # ["f", "o", "o"] > > > > anywas; it would probably pass the chars to the black *and* return an array. > > This fails when the string is encoded in a multi-byte encoding (such > as Japanese, Chinese, etc.) unless String#split is modified in the > core to split on actual logical "characters" (which might be one or > more bytes, depending on the encoding). String#split is multi-byte aware. $KCODE="EUC" a = "\xa1\xa1\xa1\xa2".split("") $KCODE="NONE" p a #=> ["\241\241", "\241\242"] Or a = "\xa1\xa1\xa1\xa2".split(//e) p a #=> ["\241\241", "\241\242"] -- Nobu Nakada