Force encoding more invalid UTF-8 characters

Byte sequence from "\x80" to "\xff" will cause `ArgumentError: invalid byte
sequence in UTF-8` when you are trying to do `URI.decode("\x80")`.

The fix is to force encode the environment variables into UTF-8, and replace
invalid characters with `?`, before handing it over to the `URIString`.