File Packing Ideas - FINAL

Thank you for your input! I now do the following:

  1. jam readlines into an array after chomping
  2. marshal the array into some funky string
  3. cgi.escape the marshaled string!!
  4. (I should compress the sucker just for good measure)
  5. (if you were really anal you could invent another step here – oo! You
    could “Captain” the escaped marshalled string array)

I shall call it, “Operation String Cheese” (pinky finger goes to evil grin)

···

-----Original Message-----
From: Vera, Michael [mailto:mxvera@qwest.com]
Sent: Tuesday, November 12, 2002 3:03 PM
To: ruby-talk@ruby-lang.org
Subject: Re: File Packing Ideas

Why am I still getting random newlines using CGI.escape? Is there a certain
maximum number of characters this module can handle?

-----Original Message-----
From: Nikodemus Siivola [mailto:tsiivola@cc.hut.fi]
Sent: Tuesday, November 12, 2002 12:15 PM
To: ruby-talk@ruby-lang.org
Subject: Re: File Packing Ideas

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

Thank you for your input! I now do the following:

  1. jam readlines into an array after chomping
  2. marshal the array into some funky string
  3. cgi.escape the marshaled string!!
  4. (I should compress the sucker just for good measure)

In that case you’ll probably want to swap 3) and 4)… :slight_smile:

  1. (if you were really anal you could invent another step here – oo! You
    could “Captain” the escaped marshalled string array)

I shall call it, “Operation String Cheese” (pinky finger goes to evil grin)

I’ll hold your cgi.escaped data hostage - for a ransom of
. . . . ONE HUNDRED DOLLARS !!!
:wink:

Regards,

Bill

···

From: “Vera, Michael” mxvera@qwest.com

Hi,

···

At Wed, 13 Nov 2002 06:35:08 +0900, Vera, Michael mxvera@qwest.com wrote:

Thank you for your input! I now do the following:

  1. jam readlines into an array after chomping
  2. marshal the array into some funky string
  3. cgi.escape the marshaled string!!
  4. (I should compress the sucker just for good measure)
  5. (if you were really anal you could invent another step here – oo! You
    could “Captain” the escaped marshalled string array)

I’m not sure why you want to split data and chomp them. Why
not just:

  1. read data into a string (with compressing)
  2. send cgi.escape(string) or string.dump


Nobu Nakada