Closed paulo242 closed 11 months ago
Value for encoding_errors parameter is NOT character set name! It's the error handler name, see https://docs.python.org/3/library/codecs.html#error-handlers
Sorry about the misuse! Is there a way to know which encoding is comming since my chatset is WIN1252 or there's a way to proper decode it to UTF-8? We tries many encode+decode but no success. The property name suggests an encoding for database errors, so it caused our misuse.
First, this is Python 3, so strings are unicode. The driver converts bytestrings from the server to unicode using connection charset. It works without problems with two exceptions:
In such cases string conversion to unicode may fail. The standard error codecs handler is used by default, which is 'strict' which means that conversion exception is thrown. You can chose different error handler like 'ignore', 'replace' or 'surrogateescape' that do not throw conversion exception.
And no, the property name DOES NOT suggest and encoding name, and especially the documentation for the config option clearly says: Handler used for encoding errors. See codecs error handlers for details.
We tested a database that uses WIN1252 and has many exceptions with special characters. So we tried:
driver_config.server_defaults.encoding_errors.value = 'cp1252'
anddriver_config.server_defaults.encoding_errors.value = 'WIN1252'
before the connection and a command that triggers an exception. The result wasn't encoded with WIN1252 and we couldn't convert it. teste_firebird_driver.zip