Dave Burt
5/30/2006 10:12:00 PM
Michael W. Ryder wrote:
> Both of those worked great. Thank you. Now I just have to figure out
> what they say. The only difference in Ruby from my past experience is
> that the returned strings include octal characters for the non-printable
> characters but I can live with that.
You're running into a feature here. If you're using IRB, or
string.inspect, or p(string), then what you're looking at is a
displayable version of the string.
The octal escapes are legal in a Ruby string literal, and represent a
single character in the string.
If you use puts(string) or print(string) or string.display, the
"interesting" characters (such as "\n" for newline, "\t" for tab, "\025"
for ASCII char 025) will be output.
"123".length #=> 3
"\n\t\025".length #=> 3
puts "\n\t\025"
=>
§
So, the data you want is in the strings; you have our bitwise (not
"logical" as in the message subject) xor.
HTH,
Dave