summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hexdump.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/hexdump.py b/hexdump.py
index aeb8c88..cbba3c9 100644
--- a/hexdump.py
+++ b/hexdump.py
@@ -32,3 +32,13 @@ def hexdump(ofs, data):
32 32
33def tohex(data): 33def tohex(data):
34 return b2a_hex(data).decode('ascii') 34 return b2a_hex(data).decode('ascii')
35
36def strescape(txt):
37 if type(txt)==bytes:
38 txt = txt.decode('cp1251')
39 txt = txt.replace("\\", "\\\\")
40 txt = txt.replace("\n", "\\n")
41 txt = txt.replace("\r", "\\r")
42 txt = txt.replace("\t", "\\t")
43 txt = txt.replace("\"", "\\\"")
44 return txt