def sanitize_uri_encoded_string(input)
      return input if input.nil?
      decoded_value = decode_string(input)
      reencode_string(decoded_value)
    end
def sanitize_uri_encoded_string(input)
      return input if input.nil?
      decoded_value = decode_string(input)
      reencode_string(decoded_value)
    end
URI.encode/decode expect the input to be in ASCII-8BIT.
 However, there could be invalid UTF-8 characters both in
 raw and percent-encoded form.

 So, first sanitize the value, then percent-decode it while
 treating as UTF-8, then sanitize the result and encode it back.

 The result is guaranteed to be UTF-8-safe.