Fix some encoding issues (pattern.db)
@@ -334,7 +334,6 @@ def encrypt_string(s, key=""):
""" Returns the given string as an encrypted bytestring.
"""
key += " "
- s = encode_utf8(s)
a = []
for i in range(len(s)):
try: a.append(chr(ord(s[i]) + ord(key[i % len(key)]) % 256).encode("latin-1"))
@@ -412,11 +411,6 @@ def _escape(value, quote=lambda string: "'%s'" % string.replace("'", "\\'")):
See also: Database.escape()
"""
# Note: use Database.escape() for MySQL/SQLITE-specific escape.
- if isinstance(value, str):
- # Strings are encoded as UTF-8.
- try: value = value.encode("utf-8")
- except:
- pass
if value in ("current_timestamp",):
# Don't quote constants such as current_timestamp.
return value
@@ -1713,7 +1707,6 @@ def xml(rows):
xml.append("\t</rows>")
xml.append("</%s>" % root)
xml = "\n".join(xml)
- xml = encode_utf8(xml)
return xml
def parse_xml(database, xml, table=None, field=lambda s: s.replace(".", "-")):
@@ -1837,7 +1830,7 @@ class json(object):
""" Returns a JSON string from the given data.
The data can be a nested structure of dict, list, str, unicode, bool, int, float and None.
"""
- if isinstance(obj, (str, unicode)):
+ if isinstance(obj, str):
return self.encode(obj)
if isinstance(obj, (int, long)): # Also validates bools, so those are handled first.
return str(obj)
