Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-core/src/lib.rs @ 52770:bbf1c52252ae
rust: add encoding.rs
This is based on encoding.py. It reads the environment variables HGENCODING,
HGENCODINGMODE, and HGENCODINGAMBIGUOUS. Currently it only supports UTF-8 and
ascii, but it could be extended to support other local encodings.
Unlike Python, it assumes all internal strings are UTF-8 and does not attempt to
fallback to latin-1 (or ui.fallbackencoding).
Nothing is using this now, but in the future command output and error messages
should transition to using it.
I replaced existing calls to `utf8_to_local` and `local_to_uf8` with direct
String/bytes methods since they were not logically converting between internal
and local encodings. Instead, they were used (for example) when an error message
happened to be stored as String but needed to be passed somewhere as bytes. The
proper fix for this will be to avoid String in the first place.
author | Mitchell Kember <mkember@janestreet.com> |
---|---|
date | Wed, 05 Feb 2025 17:35:52 -0500 |
parents | 1b7a57a5b47a |
children |
line wrap: on
line diff