mbstrdecoder is a Python library designed for robust decoding of multi-byte character strings, particularly useful when dealing with unknown or potentially malformed encodings. It aims to prevent `UnicodeDecodeError` exceptions by attempting to decode using various strategies, often leveraging the `chardet` library for encoding detection. The current version is 1.1.4, and it generally follows a minor release cadence driven by Python version support and bug fixes.
pip install mbstrdecoderVerified import paths — ran on the pinned version, not inferred.
Initialize `MbStrDecoder` with a byte string. You can optionally provide an initial `encoding` hint or let it auto-detect. The `unicode_str` attribute holds the decoded string, and `detected_encoding` shows the encoding used.
Upgrade to Python 3.9 or newer, or specify `mbstrdecoder<1.1.4` in your project dependencies.
Upgrade to version 1.1.4 or newer to ensure correct `UnicodeDecodeError` exception handling and propagation.
Ensure `chardet` is part of your project's `pip install` commands. `pip install mbstrdecoder` should handle this automatically for recent versions.