Crates.io | rust-locale |
lib.rs | rust-locale |
version | 0.1.4 |
source | src |
created_at | 2022-05-10 13:25:17.628175 |
updated_at | 2022-05-15 05:57:36.257138 |
description | POSIX.1 locale extension for Rust |
homepage | |
repository | https://github.com/a-takahashi223/rust-locale |
max_upload_size | |
id | 583972 |
size | 1,556,682 |
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.
[dependencies]
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");
assert!('\u{1361}'.is_space());
// 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.
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.