Returns: A generator of (offset, hex, str) tuples
(s)
| 183 | |
| 184 | |
| 185 | def hexdump(s): |
| 186 | """ |
| 187 | Returns: |
| 188 | A generator of (offset, hex, str) tuples |
| 189 | """ |
| 190 | for i in range(0, len(s), 16): |
| 191 | offset = f"{i:0=10x}" |
| 192 | part = s[i : i + 16] |
| 193 | x = " ".join(f"{i:0=2x}" for i in part) |
| 194 | x = x.ljust(47) # 16*2 + 15 |
| 195 | part_repr = always_str( |
| 196 | escape_control_characters( |
| 197 | part.decode("ascii", "replace").replace("\ufffd", "."), False |
| 198 | ) |
| 199 | ) |
| 200 | yield (offset, x, part_repr) |
| 201 | |
| 202 | |
| 203 | def _move_to_private_code_plane(matchobj): |
nothing calls this directly
no test coverage detected
searching dependent graphs…