[sysadmin-bin: 104/168] Fix encoding handling for non-ascii literals



commit 2966f3b7590ccff88bb9f8b90852230fba88754d
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Fri Apr 24 19:31:33 2009 -0400

    Fix encoding handling for non-ascii literals
    
    Decode unicode strings to UTF-8.

 semi_rdf.py |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/semi_rdf.py b/semi_rdf.py
index 6079f85..8a27414 100755
--- a/semi_rdf.py
+++ b/semi_rdf.py
@@ -189,7 +189,10 @@ def _dump_node(f, node, lang, namespaces, depth=0):
             f.write("/>\n")
         elif isinstance(v, basestring):
             f.write(">")
-            f.write(escape(v))
+            if isinstance(v, str):
+                f.write(escape(v))
+            else:
+                f.write(escape(v).decode("utf8"))
             f.write('</%s>\n' % qualname(n, namespaces))
         elif v == None:
             f.write("/>\n");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]