# UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

- **ID:** `python/flask-unicode-decode-error`
- **Domain:** python
- **Category:** encoding_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

`request.data.decode()` or reading a form field assumed UTF-8 but the client sent another encoding (e.g., Windows-1252 or binary).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 2.x | active | — | — |
| 3.x | active | — | — |

## Workarounds

1. **** (92% success)
   ```
   charset = request.mimetype_params.get('charset', 'utf-8')
text = request.data.decode(charset)
   ```
2. **** (90% success)
   ```
   try:
    text = request.data.decode('utf-8')
except UnicodeDecodeError:
    return jsonify(error='invalid encoding'), 400
   ```

## Dead Ends

- **** — Silently drops bytes; corrupts data. (75% fail)
- **** — Output config, not input decoding. (90% fail)
