MCPcopy Create free account
hub / github.com/RustPython/RustPython / get_locale_info

Function get_locale_info

crates/vm/src/format.rs:14–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12/// Get locale information from C `localeconv()` for the 'n' format specifier.
13#[cfg(unix)]
14pub(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))]
41pub(crate) fn get_locale_info() -> LocaleInfo {

Callers 3

__format__Method · 0.85
__format__Method · 0.85
__format__Method · 0.85

Calls 6

newFunction · 0.85
parse_groupingFunction · 0.85
to_stringMethod · 0.80
into_ownedMethod · 0.80
localeconvFunction · 0.50
to_string_lossyMethod · 0.45

Tested by

no test coverage detected