From: ts Date: 2001-12-17T03:20:51+09:00 Subject: [ruby-talk:28700] Re: How do you do "character filtering" of a string using each_byte. II >>>>> "D" == David Alan Black writes: D> On Mon, 17 Dec 2001, Thaddeus L. Olczyk wrote: >> For the truely intelligent who try this, thanks. Personnaly, I'm really stupid D> I take it that you MUST use String#each_byte, so here: Well it exist always a possibility to write stupid thing :-)) D> str.each_byte {|b| [...] D> } str = "hello 123 I am a String" str.gsub!(/./m) do |b| case b when /[[:lower:]]/ "\\x" + "%x" % b[0] # this is % that you want ? else b end end p str Guy Decoux