File tree Expand file tree Collapse file tree
src/uucore/src/lib/features/i18n Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -41,11 +41,24 @@ fn get_effective_ctype_locale() -> Option<String> {
4141
4242/// Return whether the effective `LC_CTYPE` locale is the byte-oriented C/POSIX locale.
4343///
44- /// A missing effective locale defaults to POSIX behavior. Only exact `C` and
45- /// `POSIX` locale values are treated as explicit C/POSIX locales; locales such
46- /// as `C.UTF-8` are not.
44+ /// WASI has no native locale environment, so it keeps the existing
45+ /// UTF-8-compatible behavior regardless of forwarded locale variables.
46+ # [ cfg ( target_os = "wasi" ) ]
4747pub fn is_effective_ctype_c_or_posix ( ) -> bool {
48- get_effective_ctype_locale ( ) . is_none_or ( |locale| locale == "C" || locale == "POSIX" )
48+ false
49+ }
50+
51+ /// Return whether the effective `LC_CTYPE` locale is the byte-oriented C/POSIX locale.
52+ ///
53+ /// A missing effective locale defaults to POSIX behavior on platforms with a
54+ /// native locale environment.
55+ #[ cfg( not( target_os = "wasi" ) ) ]
56+ pub fn is_effective_ctype_c_or_posix ( ) -> bool {
57+ match get_effective_ctype_locale ( ) . as_deref ( ) {
58+ Some ( "C" | "POSIX" ) => true ,
59+ Some ( _) => false ,
60+ None => true ,
61+ }
4962}
5063
5164fn get_encoding ( ) -> & ' static MbEncoding {
Original file line number Diff line number Diff line change @@ -983,6 +983,7 @@ fn test_posixly_correct_whitespace() {
983983}
984984
985985#[ test]
986+ #[ cfg_attr( wasi_runner, ignore = "WASI has no native C/POSIX locale" ) ]
986987fn test_wc_chars_c_locale ( ) {
987988 // In C/POSIX locale, wc -m should count bytes, not UTF-8 characters
988989 // Vietnamese "Tiếng Việt" uses diacritics (2 bytes per char in UTF-8)
@@ -1057,6 +1058,7 @@ fn test_wc_chars_utf8_locale() {
10571058}
10581059
10591060#[ test]
1061+ #[ cfg_attr( wasi_runner, ignore = "WASI has no native C/POSIX locale" ) ]
10601062fn test_wc_chars_default_locale ( ) {
10611063 // When no locale is set (empty LC_ALL), it defaults to POSIX (chars == bytes)
10621064 // This ensures backward compatibility
@@ -1084,6 +1086,7 @@ fn test_wc_chars_default_locale() {
10841086}
10851087
10861088#[ test]
1089+ #[ cfg_attr( wasi_runner, ignore = "WASI has no native C/POSIX locale" ) ]
10871090fn test_wc_multibyte_c_locale ( ) {
10881091 // Issue #9712 and #5831: Test various multibyte characters in C locale
10891092 // All should be counted as bytes
You can’t perform that action at this time.
0 commit comments