module Ethon::Easy::Util
This module contains small helpers.
@api private
Public Instance Methods
escape_zero_byte(value)
click to toggle source
Escapes zero bytes in strings.
@example Escape zero bytes.
Util.escape_zero_byte("1\0") #=> "1\\0"
@param [ Object ] value The value to escape.
@return [ String, Object ] Escaped String if
zero byte found, original object if not.
# File lib/ethon/easy/util.rb, line 20 def escape_zero_byte(value) return value unless value.to_s.include?(0.chr) value.to_s.gsub(0.chr, '\\\0') end