mirror of
https://git.sr.ht/~rjarry/aerc
synced 2026-09-28 12:01:57 +02:00
`set_stdio_encoding()` assumed `setlocale(LC_ALL, "")` returns NULL when `LANG`/`LC_ALL` are unset, and only fell back to "C.UTF-8"/"UTF-8" in that case. In practice, POSIX libc implementations return the non-NULL string "C" in that situation, so the fallback was never taken. "C"'s codeset is US-ASCII, so wrap exited with: error: locale 'C' is not UTF-8 Add `locale_supports_utf8()` to check the actual codeset instead of just checking for NULL, and use it to gate every step of the fallback chain, including the final result. This also fixes the same failure when `LANG` names a real but non-UTF-8 locale (e.g. `LANG=en_US.ISO8859-1`), which previously skipped the fallback entirely instead of trying "C.UTF-8"/"UTF-8". Changelog-fixed: Fix wrap filter when `LANG` or `LC_ALL` are unset. Previously it would error out. Signed-off-by: Tristan Partin <tristan@partin.io> Acked-by: Robin Jarry <robin@jarry.cc>