mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-08 19:31:14 -03:00
Force libc wcwidth to use UTF-8 locale again
Commit046db09f90(Try to set LC_CTYPE to something UTF-8 capable (#8031), 2021-06-06) forced UTF-8 encoding if available. Sincec8001b5023(encoding: use UTF-8 everywhere, 2025-10-18) we no longer override LC_CTYPE, since we no longer use it for anything like mbrtowc or iswalpha. However there is one remaining use: our fallbacks to system wcwidth(). If we are started as LC_ALL=C fish then wcwidth('😃') will fail to return the correct value, even if the UTF-8 locale would have been available. Restore the previous behavior, so locale variables don't affect emoji width. This is consistent with the direction inc8001b5023which stops us from falling back to ASCII characters if our desired multibyte locale is missing (that was not the ideal criteria). In future we should maybe stop using wcwidth().
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
/// Call this either before starting any locale-using thread, or while holding a lock on the
|
||||
/// above mutex.
|
||||
pub unsafe fn set_libc_locales() -> Option<&'static CStr> {
|
||||
setlocale(libc::LC_ALL, Some(c""))
|
||||
let opaque_locale_str = setlocale(libc::LC_ALL, Some(c""));
|
||||
setlocale(libc::LC_CTYPE, Some(c"C.UTF-8"));
|
||||
opaque_locale_str
|
||||
}
|
||||
|
||||
fn setlocale(category: libc::c_int, locale: Option<&CStr>) -> Option<&'static CStr> {
|
||||
|
||||
Reference in New Issue
Block a user