def ensure_ascii_compatible_encoding(string, options = nil)
      if string.encoding.ascii_compatible?
        string
      else
        string.encode(Encoding::UTF_8, options || {:invalid => :replace, :undef => :replace})
      end
    end
def ensure_ascii_compatible_encoding(string, options = nil)
      if string.encoding.ascii_compatible?
        string
      else
        string.encode(Encoding::UTF_8, options || {:invalid => :replace, :undef => :replace})
      end
    end
Returns string as-is if it is ASCII-compatible
 (that is, if you are interested in 7-bit characters exposed as #bytes).
 If it is not, attempts to transcode to UTF8 replacing invalid characters if there are any.
 If options are not specified, uses safe default that replaces unknown characters with standard character.
 If options are specified, they are used as-is for String#encode method.