Decode a short string value from ``encoded`` data at ``offset``.
(encoded: bytes,
offset: int)
| 42 | |
| 43 | |
| 44 | def decode_short_string(encoded: bytes, |
| 45 | offset: int) -> Tuple[Union[str, bytes], int]: |
| 46 | """Decode a short string value from ``encoded`` data at ``offset``. |
| 47 | """ |
| 48 | length = struct.unpack_from('B', encoded, offset)[0] |
| 49 | offset += 1 |
| 50 | value = encoded[offset:offset + length] |
| 51 | try: |
| 52 | value = value.decode('utf8') # type: ignore[assignment] |
| 53 | except UnicodeDecodeError: |
| 54 | pass |
| 55 | offset += length |
| 56 | return value, offset |
| 57 | |
| 58 | |
| 59 | def encode_table(pieces: List[bytes], table: Optional[Dict[str, Any]]) -> int: |
no test coverage detected
searching dependent graphs…