Remove all Ascii non-printable chars from a string

#1

Anyone know how to do this?

Example input and output

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

0 Likes

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

#3

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

0 Likes