summaryrefslogtreecommitdiff
path: root/scripts/asmquote.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/asmquote.py')
-rw-r--r--scripts/asmquote.py27
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