Yield Unicode strings (ASCII) from a buf string of binary data. :param buf: A bytestring. :type buf: str :param n: The minimum length of strings to extract. :type n: int :rtype: Sequence[string]
(buf, n=3)
| 29 | |
| 30 | |
| 31 | def extract_ascii_strings(buf, n=3): |
| 32 | """ |
| 33 | Yield Unicode strings (ASCII) from a buf string of binary data. |
| 34 | |
| 35 | :param buf: A bytestring. |
| 36 | :type buf: str |
| 37 | :param n: The minimum length of strings to extract. |
| 38 | :type n: int |
| 39 | :rtype: Sequence[string] |
| 40 | """ |
| 41 | if not buf: |
| 42 | return |
| 43 | |
| 44 | reg = '([%s]{%d,})' % (ASCII_BYTE, n) |
| 45 | r = re.compile(reg) |
| 46 | for match in r.finditer(buf): |
| 47 | yield match.group().decode('ascii') |
| 48 | |
| 49 | |
| 50 | def extract_unicode_strings(buf, n=3): |
no test coverage detected