On Wed, 13 Nov 2002, Vera, Michael wrote:

> I am looking for help to solve this problem I have. I need to read in a
> file, and convert it into a single line string with no characters readable
> in it, (such as \n, \t, etc.) so that it can be sent over a socket
> connection and reconverted on the other side.

The CGI class solves this problem for you: URL's need to be escaped as
well.

irb(main):001:0> require 'cgi'
true
irb(main):002:0> str = "\n\f\r\b"
"\n\f\r\010"
irb(main):003:0> str2 = CGI.escape str
"%0A%0C%0D%08"
irb(main):004:0> str == CGI.unescape(str2)
true
irb(main):005:0>

  -- Nikodemus