Patrick D. wrote:
This won’t help much, but when I executed:
ASCII = (0…255).map{|c| c.chr }
PRINTABLE = ASCII.grep(/[[:print:]]/)
PRINTABLE.length
191
in irb, I got 95 on my ruby 1.8.6 (i386-mswin32) running on an XP box.
What were the 191 characters displayed when computed the PRINTABLE
expression?
A slightly more plausible explanation might be that [[:print:]] alters
its
behavior based on the TERM environment variable. What is ENV[“TERM”] in
the
two cases?
That’s all I’ve got. I warned you at the beginning that this wouldn’t
help
much.
–wpd
I mentioned that i used the same terminal to verify that it was not a
terminal issue. I tried both out with TERM=screen (my usual), then
xterm-color, xterm-256color and perhaps VT100 and VT200 as well.
One of the characters in the 191 for example is 165 or “\245” which is
the code generated by Alt-A on my MAC OSX (powerpc, 10.5.5, darwin).
(This is when i have not enabled “Use alt as meta” - if you dont know
what that is just ignore, its a MAC default).
Here’s the dump, since you asked:
irb(main):030:0> PRINTABLE
[" “, “!”, “””, “#”, “$”, “%”, “&”, “’”, “(”, “)”, “*”, “+”, “,”, “-”,
“.”, “/”, “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “:”, “;”,
“<”, “=”, “>”, “?”, “@”, “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”,
“J”, “K”, “L”, “M”, “N”, “O”, “P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”,
“X”, “Y”, “Z”, “[”, “\”, “]”, “^”, “_”, “`”, “a”, “b”, “c”, “d”, “e”,
“f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”,
“t”, “u”, “v”, “w”, “x”, “y”, “z”, “{”, “|”, “}”, “~”, “\240”, “\241”,
“\242”, “\243”, “\244”, “\245”, “\246”, “\247”, “\250”, “\251”, “\252”,
“\253”, “\254”, “\255”, “\256”, “\257”, “\260”, “\261”, “\262”, “\263”,
“\264”, “\265”, “\266”, “\267”, “\270”, “\271”, “\272”, “\273”, “\274”,
“\275”, “\276”, “\277”, “\300”, “\301”, “\302”, “\303”, “\304”, “\305”,
“\306”, “\307”, “\310”, “\311”, “\312”, “\313”, “\314”, “\315”, “\316”,
“\317”, “\320”, “\321”, “\322”, “\323”, “\324”, “\325”, “\326”, “\327”,
“\330”, “\331”, “\332”, “\333”, “\334”, “\335”, “\336”, “\337”, “\340”,
“\341”, “\342”, “\343”, “\344”, “\345”, “\346”, “\347”, “\350”, “\351”,
“\352”, “\353”, “\354”, “\355”, “\356”, “\357”, “\360”, “\361”, “\362”,
“\363”, “\364”, “\365”, “\366”, “\367”, “\370”, “\371”, “\372”, “\373”,
“\374”, “\375”, “\376”, “\377”]