()
| 12 | /// Get locale information from C `localeconv()` for the 'n' format specifier. |
| 13 | #[cfg(unix)] |
| 14 | pub(crate) fn get_locale_info() -> LocaleInfo { |
| 15 | use core::ffi::CStr; |
| 16 | unsafe { |
| 17 | let lc = libc::localeconv(); |
| 18 | if lc.is_null() { |
| 19 | return LocaleInfo { |
| 20 | thousands_sep: String::new(), |
| 21 | decimal_point: ".".to_string(), |
| 22 | grouping: vec![], |
| 23 | }; |
| 24 | } |
| 25 | let thousands_sep = CStr::from_ptr((*lc).thousands_sep) |
| 26 | .to_string_lossy() |
| 27 | .into_owned(); |
| 28 | let decimal_point = CStr::from_ptr((*lc).decimal_point) |
| 29 | .to_string_lossy() |
| 30 | .into_owned(); |
| 31 | let grouping = parse_grouping((*lc).grouping); |
| 32 | LocaleInfo { |
| 33 | thousands_sep, |
| 34 | decimal_point, |
| 35 | grouping, |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | #[cfg(not(unix))] |
| 41 | pub(crate) fn get_locale_info() -> LocaleInfo { |
no test coverage detected