- 'pos'. The decoded data is prefixed with 'label'. If 'excape_all' is
- True, all data bytes are escaped as hex codes.'''
-
- def escape(b):
- c = chr(b)
- if escape_all or not str.isprintable(c):
- return '\\x{:02X}'.format(b)
- return c
+ 'pos'. The decoded data is prefixed with 'label'. If 'always_hex' is
+ True, all bytes are decoded as hex codes, otherwise only non
+ printable characters are escaped.'''
+
+ if always_hex:
+ def escape(b):
+ return '{:02X}'.format(b)
+ else:
+ def escape(b):
+ c = chr(b)
+ if not str.isprintable(c):
+ return '\\x{:02X}'.format(b)
+ return c