From: daz Date: 2004-05-13T11:18:52+09:00 Subject: Re: String#unpack and null-terminated strings Yukihiro Matsumoto wrote: > Hi. > > In message "Re: String#unpack and null-terminated strings" > on 04/05/12, nobu.nokada@softhome.net writes: > > |At Mon, 10 May 2004 17:53:35 +0900, > |Yukihiro Matsumoto wrote in [ruby-talk:99719]: > |> I finally got time to consider this issue. Perl seems to work the way > |> Daz described in [ruby-talk:98364]. Could you commit the changes, Nobu? > | > |What about 1.8? > > Hmm. Go ahead. I now think it's the only reasonable behavior for "Z" > with NUL containing strings. > > matz. > Thanks, Matz. The plea below is now wasted :)) =============================================================== Hi Nobu, Good to see your return, as always. As the changes only affects 'Z'-types in Strings with embedded null(s), the impact should be extremely low. I'm trying to think of any kind of string which might contain significant nulls but also has a null as terminator. I've seen some where null delimits fields and double-null terminates but that rare case might be the only one to break *iff* a programmer had decided that the best method to use on that type of string was unpack('Z*'). Embedded nulls are common when reading from binary files (e.g. encoded characters) but I feel that it would never be a good idea to strip _trailing_ nulls in that context. Voting +1 for inclusion in 1.8, also. Much more usable :-) Thanks, daz ===============================================================