From: Yohanes Santoso Date: 2002-12-16T23:42:00+09:00 Subject: Re: a range with all the ascii chars -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 gabriele renzi writes: > Hi, gurus > > I know that ruby handles unicode, and I suppose it handles ascii as a > subset of unicode, m need is to have a Range like > "\000\000\000".."\255\255\255" [1] > > or, if you like, this more: > "aaa".."zzz"+$all_the_strange_chars > > I tried to use the previous [1] way to obtain this, but it seems to > fail, giving me an array with 58 (!) elements. > How could I iterate over strings like this ? (0..0xFFFFFF).each{|i| a = [i>>16&0xFF, i>>8&0xFF, i&0xFF].pack("c*"); # Now we test if the packing is right a.each_byte{|b| print "#{"%02X"%b} "}; puts;} # And it is, it outputs: # 00 00 00 # 00 00 01 # ...... # FF FF FE # FF FF FF } YS. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) Comment: Processed by Mailcrypt 3.5.8 iD8DBQE9/eYrEOgCkEGX4MIRAo+EAJ4q8iMgzlXeDfbPLexbuwXB8XlwJwCeKlrc 4GugqyJXX4uIdr+YiyXzgfs= =sg/M -----END PGP SIGNATURE-----