Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b820975

Browse files
committed
Improvement of decodeIntToUnicode()
1 parent 1153b45 commit b820975

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

lib/core/common.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,16 +2523,23 @@ def openFile(filename, mode='r'):
25232523

25242524
def decodeIntToUnicode(value):
25252525
"""
2526-
Decodes inferenced integer value with usage of current page encoding
2526+
Decodes inferenced integer value to an unicode character
25272527
"""
2528-
try:
2529-
# http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_ord
2530-
if Backend.getIdentifiedDbms() in (DBMS.MYSQL,) or conf.charset:
2531-
return struct.pack('B' if value < 256 else '<H', value).decode(kb.pageEncoding or UNICODE_ENCODING)
2532-
else:
2533-
return unichr(value)
2534-
except:
2535-
return INFERENCE_UNKNOWN_CHAR
2528+
retVal = value
2529+
2530+
if isinstance(value, int):
2531+
try:
2532+
# http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_ord
2533+
if Backend.getIdentifiedDbms() in (DBMS.MYSQL,):
2534+
retVal = getUnicode(struct.pack('B' if value < 256 else '<H', value))
2535+
elif value > 255:
2536+
retVal = unichr(value)
2537+
else:
2538+
retVal = getUnicode(chr(value))
2539+
except:
2540+
retVal = INFERENCE_UNKNOWN_CHAR
2541+
2542+
return retVal
25362543

25372544
def unhandledExceptionMessage():
25382545
"""

0 commit comments

Comments
 (0)