From fcdc2a7217cab02148f9f92b11f189079936314f Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sun, 10 Aug 2008 20:31:04 +0200 Subject: [PATCH] better character escapes in C code: oct works better than hex, escape line ending characters --- Cython/Utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cython/Utils.py b/Cython/Utils.py index 5a23b58e..4ab111b2 100644 --- a/Cython/Utils.py +++ b/Cython/Utils.py @@ -100,7 +100,7 @@ class EncodedString(unicode): # getattr(other, 'encoding', '') == self.encoding def escape_byte_string(s): - s = s.replace('\0', r'\x00') + s = s.replace('\0', r'\000').replace('\x0A', r'\012').replace('\x0C', r'\014') try: s.decode("ASCII") return s @@ -111,7 +111,7 @@ def escape_byte_string(s): for c in s: o = ord(c) if o >= 128: - append('\\x%X' % o) + append('\\%3o' % o) else: append(c) return ''.join(l) -- 2.26.2