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.
I have tried pack, Marshal, and gsub, and different combinations. The
closest I got was readline-ing the file into an array, chomping the newlines
out, and marshalling the array into a string. This seemed to work until I
tried to send a \n within the text. So I added a gsub(/\n/, ‘0x0a’) when
pushing into the array. This seemed to work until I sent a \t, or maybe it
was the Marshal.dump() text that was sent?!?
Does anyone have any good ideas how I can pack all my files into a one-liner
string? Or will I have to go beg A*L for their latest protocol and see how
they do it?