Peek a string. Get string's length first (stored as a size_t), then get number of bytes equivalents to the length. Default using utf-8 to decode, if there is any bytes cannot be converted, 'errors="backslashreplace' inserts a escape sequence.So these special b
(self)
| 68 | return byt |
| 69 | |
| 70 | def get_string(self): |
| 71 | """Peek a string. |
| 72 | Get string's length first (stored as a size_t), then get number of bytes |
| 73 | equivalents to the length. |
| 74 | Default using utf-8 to decode, if there is any bytes cannot be converted, |
| 75 | 'errors="backslashreplace' inserts a escape sequence.So these special |
| 76 | bytes can be reserved. |
| 77 | Ref:https://docs.python.org/3/howto/unicode.html?highlight=bytes%20decode |
| 78 | """ |
| 79 | size = self.get_size() |
| 80 | string = ( |
| 81 | self.get_block(size).tobytes().decode("utf-8", errors="backslashreplace") |
| 82 | ) |
| 83 | return string |
| 84 | |
| 85 | def get_int(self): |
| 86 | """Peek a int.""" |
no test coverage detected