5 releases

0.1.4 May 15, 2022
0.1.3 May 14, 2022
0.1.2 May 14, 2022
0.1.1 May 14, 2022
0.1.0 May 10, 2022

#110 in Internationalization (i18n)

22 downloads per month


2.5K SLoC

C 1.5K SLoC // 0.2% comments Automake 702 SLoC // 0.2% comments Rust 210 SLoC



rust_locale provides various functions dependent on locale specified in POSIX.1.

The main purpose is to provide something that is not in char methods or that differs in behavior from char methods.


rust-locale = "0.1"


use rust_locale::CType;

// space is different from whitespace
assert!('\x0c'.is_space());  # form feed
std::env::set_var("LC_ALL", "en_US");
assert!('\u{2003}'.is_space());  # Em Space
assert!(!'\u{1361}'.is_space());  # Ethiopic Wordspace
std::env::set_var("LC_ALL", "am_ET");

// different behavior from char::to_uppercase
std::env::set_var("LC_ALL", "en_US");
assert_eq!(CType::to_uppercase(&'i'), 'I');
std::env::set_var("LC_ALL", "tr_TR");
assert_eq!(CType::to_uppercase(&'i'), '\u{0130}');  # Latin Capital Letter I with Dot Above

These tests may fail depending on the locales' definition.

Future plan

Feature requests are welcome.


rust-locale uses Gnulib for the platform compatibility. Gnulib is LGPL and rust-locale links to it statically, therefore rust-locale is also LGPL.

If you use rust-locale and not want to adapt LGPL, you may need to link to rust-locale dynamically.
If that is difficult, I will consider linking rust-locale to Gnulib dynamically and change rust-locale's license to MIT.