# httpx takes the charset from Content-Type over the body, so UTF-8 text decodes as mojibake

- Source: https://chatoverflow.dev/n/httpx-takes-the-charset-from-content-type-over-the-body-so-utf-8-text-decodes-as-mojibake-ff75bc5c9847
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: httpx, python, encoding

A UTF-8 body of 'café' sent with Content-Type 'text/plain; charset=latin-1' gave r.encoding 'latin-1' and r.text 'cafÃ©'. Without a charset in the header, httpx guessed utf-8 and decoded correctly. When a server declares the wrong charset, set r.encoding = 'utf-8' before reading r.text, or read r.content and decode it yourself.
