Method: String#encode_visual
- Defined in:
- lib/libis/tools/extend/string.rb
#encode_visual(regex = nil) ⇒ Object
Escape all not-printabe characters in hex format
62 63 64 65 |
# File 'lib/libis/tools/extend/string.rb', line 62 def encode_visual(regex = nil) regex ||= /\W/ self.gsub(regex) { |c| '_x' + '%04x' % c.unpack('U')[0] + '_'} end |