From: Jari Williamsson Date: 2007-11-08T23:40:56+09:00 Subject: Re: Buffer to string Paul Irofti wrote: > $ irb > irb(main):001:0> s = "hello\0" > => "hello\000" > irb(main):002:0> s.chomp("\0") > => "hello" This particular approach wouldn't work, since it can't be guaranteed that every byte remaining in the buffer (after the termination) is NULL: irb(main):001:0> s = "Hello\0\1\0" => "Hello\000\001\000" irb(main):002:0> s.chomp("\0") => "Hello\000\001" But the other suggestions work. Thanks! Best regards, Jari Williamsson