Decodes the encoded data with the specified encoding. Args: encoded_data (bytes): The data to decode. encoding (Encoding): The encoding type. Returns: str: The decoded string.
(self, encoded_data: bytes, encoding: Encoding)
| 100 | return self.decode_with_encoding(encoded_data, encoding) |
| 101 | |
| 102 | def decode_with_encoding(self, encoded_data: bytes, encoding: Encoding) -> str: |
| 103 | """ |
| 104 | Decodes the encoded data with the specified encoding. |
| 105 | |
| 106 | Args: |
| 107 | encoded_data (bytes): The data to decode. |
| 108 | encoding (Encoding): The encoding type. |
| 109 | |
| 110 | Returns: |
| 111 | str: The decoded string. |
| 112 | """ |
| 113 | if encoding == Encoding.LOWER_SPECIAL: |
| 114 | return self._decode_lower_special(encoded_data) |
| 115 | elif encoding == Encoding.LOWER_UPPER_DIGIT_SPECIAL: |
| 116 | return self._decode_lower_upper_digit_special(encoded_data) |
| 117 | elif encoding == Encoding.FIRST_TO_LOWER_SPECIAL: |
| 118 | return self._decode_rep_first_lower_special(encoded_data) |
| 119 | elif encoding == Encoding.ALL_TO_LOWER_SPECIAL: |
| 120 | return self._decode_rep_all_to_lower_special(encoded_data) |
| 121 | elif encoding == Encoding.UTF_8: |
| 122 | return encoded_data.decode("utf-8") |
| 123 | else: |
| 124 | raise ValueError(f"Unexpected encoding flag: {encoding}") |
| 125 | |
| 126 | def _decode_lower_special(self, data: bytes) -> str: |
| 127 | """ |
no test coverage detected