diff --git a/ll.py b/ll.py index 81a9415..3fa27d7 100644 --- a/ll.py +++ b/ll.py @@ -217,6 +217,17 @@ def gdecl2s(gdecl): .format(gdecl.name, ty2s(gdecl.ty), ginit2s(gdecl.body))) -def ll_encode(s): - # TODO - return s +def ll_encode(string): + res_l = [] + 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)