Implement encoding LLVM strings.
This commit is contained in:
parent
7cd2560956
commit
0536c7e683
17
ll.py
17
ll.py
|
@ -217,6 +217,17 @@ def gdecl2s(gdecl):
|
||||||
.format(gdecl.name, ty2s(gdecl.ty), ginit2s(gdecl.body)))
|
.format(gdecl.name, ty2s(gdecl.ty), ginit2s(gdecl.body)))
|
||||||
|
|
||||||
|
|
||||||
def ll_encode(s):
|
def ll_encode(string):
|
||||||
# TODO
|
res_l = []
|
||||||
return s
|
for c in string:
|
||||||
|
code = ord(c)
|
||||||
|
if code <= 31 or code == 127:
|
||||||
|
res_l.append('\{:02X}'.format(code))
|
||||||
|
elif c == '\\':
|
||||||
|
res_l.append('\\\\')
|
||||||
|
elif c == '"':
|
||||||
|
res_l.append('\\22')
|
||||||
|
else:
|
||||||
|
res_l.append(c)
|
||||||
|
|
||||||
|
return ''.join(res_l)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user