backend/server/importlib/backendLib.py | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 1561c9278dca728a67d3c22505d64075553260e9
Author: Joshua Roys <joshua.roys(a)gtri.gatech.edu>
Date: Wed Jan 20 11:38:56 2010 -0500
528214 - Encode DBstrings as utf-8 bytes before truncating
If they are left as utf-8 strings and not converted to their
corresponding byte sequence, python treats a multi-byte utf-8
character as one unit. This causes confusion for things like
splices, especially the one right below this patch; that splice
tries to limit the length of the string to the maximum supported
by the database schema, but fails to do so as it is operating on
a utf-8 string rather than a byte string.
Side note: NLS_LANG must be set to an appropriate utf-8 locale.
diff --git a/backend/server/importlib/backendLib.py
b/backend/server/importlib/backendLib.py
index b7e4145..1166892 100644
--- a/backend/server/importlib/backendLib.py
+++ b/backend/server/importlib/backendLib.py
@@ -464,6 +464,8 @@ def sanitizeValue(value, datatype):
if isinstance(datatype, DBstring):
if value is None:
value = ''
+ elif isinstance(value, unicode):
+ value = unicode.encode(value, 'utf-8')
return value[:datatype.limit]
if isinstance(datatype, DBblob):
if value is None:
Show replies by date