From: "Hal E. Fulton" Date: 2003-07-16T02:38:15+09:00 Subject: Re: Determining if a String is marshalled ----- Original Message ----- From: "Daniel Berger" To: "ruby-talk ML" Sent: Tuesday, July 15, 2003 11:38 AM Subject: Re: Determining if a String is marshalled > > Of course, the string might actually start with those bytes, but they are > > low ("\004\006" on my machine) so unlikely to occur in a normal string. > > > > Regards, > > > > Brian. > > Thanks Brian and Matz for the info. My only concern might be that a > pack'd string would inadvertantly pass this test. I guess that's what > begin/rescue is for, though. :) Hmm, assuming a packed string can have an arbitrary value, this could easily happen (probability 1/65536). Here's a silly idea. When you Marshal a string, add a singleton to it (that does nothing). Test for that later. str.respond_to? :marshalled # it's a marshalled string However, that only works for strings in memory, of course. If you read it in from a file... who knows? Hal -- Hal Fulton hal9000@hypermetrics.com