Bug fix for international letters decoded with --hex on MsSQL

This commit is contained in:
Miroslav Stampar 2012-10-28 11:50:16 +01:00
parent ca427af8b3
commit 8617fe0d65

View File

@ -3209,16 +3209,11 @@ def decodeHexValue(value):
if value.lower().startswith("0x"): if value.lower().startswith("0x"):
value = value[2:] value = value[2:]
value = value.decode("hex") value = value.decode("hex")
if len(value) > 1 and value[1] == '\x00': if Backend.isDbms(DBMS.MSSQL):
try: try:
value = value.decode("utf-16-le") value = value.decode("utf-16-le")
except UnicodeDecodeError: except UnicodeDecodeError:
pass pass
elif value and value[0] == '\x00':
try:
value = value.decode("utf-16-be")
except UnicodeDecodeError:
pass
if not isinstance(value, unicode): if not isinstance(value, unicode):
value = value.decode("utf8", "replace") value = value.decode("utf8", "replace")
return value return value