diff options
author | Háčky <hatschky@gmail.com> | 2014-11-27 07:15:45 +0000 |
---|---|---|
committer | Háčky <hatschky@gmail.com> | 2014-11-27 07:15:45 +0000 |
commit | 319ed6d0e0266f5f6174a5acd929914db8cfae1d (patch) | |
tree | 76408d9cadcbed1e702efa8c44f4cf5e364b0a4d /scripts/asmquote.py | |
parent | 17853b802692237d98f96d1a80caf2019f71753e (diff) |
Diffstat (limited to 'scripts/asmquote.py')
-rw-r--r-- | scripts/asmquote.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/scripts/asmquote.py b/scripts/asmquote.py new file mode 100644 index 0000000..cfc1440 --- /dev/null +++ b/scripts/asmquote.py @@ -0,0 +1,27 @@ +asmProblemBytes = ['\x00', '\x09', '\x0A', '\x22'] +def asmQuote(t): + result = "" + quoted = False + if t[0] in asmProblemBytes: + result = '{0}'.format(ord(t[0])) + else: + result = '"' + t[0] + quoted = True + t = t[1:] + + while len(t): + if quoted and t[0] in asmProblemBytes: + result += '",{0}'.format(ord(t[0])) + quoted = False + elif quoted: + result += t[0] + elif t[0] in asmProblemBytes: + result += ',{0}'.format(ord(t[0])) + quoted = False + else: + result += ',"' + t[0] + quoted = True + t = t[1:] + if quoted: + result += '"' + return result
\ No newline at end of file |