Remove all Ascii non-printable chars from a string

Anyone know how to do this?

Example input and output

input = “\x00H\x11E\x09LLO!”
output = “HELLO!”

input = "\x00H\x11E\x09LLO!"
output = input.delete { |char| char.ord < 32 }
puts output

You may also be interested by https://github.com/j8r/unicode_blocr

1 Like