[gegl] cltostring.py: Don't pretend to handle unicode



commit 368b99a56a6c2e51cb3068a79f66b67d22a6b220
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Mon Oct 28 13:23:19 2013 -0700

    cltostring.py: Don't pretend to handle unicode
    
    This isn't really the correct way to do things, but
    it will work in both python 2 and 3 as long as the
    .cl files are actually ascii.

 opencl/cltostring.py |   18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/opencl/cltostring.py b/opencl/cltostring.py
index d2f9b7c..bf8f46e 100755
--- a/opencl/cltostring.py
+++ b/opencl/cltostring.py
@@ -27,16 +27,14 @@ def do_includes (source):
   return "\n".join(result)
 
 # From http://stackoverflow.com/questions/14945095/how-to-escape-string-for-generated-c
-def escape_string(s, encoding='ascii'):
-   if isinstance(s, unicode):
-      s = s.encode(encoding)
-   result = ''
-   for c in s:
-      if not (32 <= ord(c) < 127) or c in ('\\', '"'):
-         result += '\\%03o' % ord(c)
-      else:
-         result += c
-   return result
+def escape_string(s):
+  result = ''
+  for c in s:
+    if not (32 <= ord(c) < 127) or c in ('\\', '"'):
+      result += '\\%03o' % ord(c)
+    else:
+      result += c
+  return result
 
 
 infile  = open(sys.argv[1], "r")


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