This is a library that converts strings representing locale names to code pages that are used in Windows.
e.g.
en-US
locale, Windows-1252 (code page id: 1252
) is used as the ANSI code page, and CP437 (code page id: 437
) is used as the OEM code page.ja-JP
locale, Shift_JIS (code page id: 932
) is used as both of the ANSI and OEM code pages.First, add locale_name_code_page = "<2"
to your Cargo.toml
.
```toml [dependencies]
localenamecode_page = "<2"
```
Then, convert strings representing locales to code pages like:
```rust use localenamecodepage::getcodepage; use localenamecodepage::cptable_type::CodePage;
// IConverter has already been defined by you
fn getconverterinstance(codepage: &CodePage) -> Box
// snip
fn main() { // snip if let Some(codepageref) = getcodepage(localestring) { let converter = getconverterinstance(codepageref); // snip } else { eprintln!("Error: {} doesn't represent a valid locale.", locale_string); std::process::exit(1); } } ```
Obtained codepage (instance of locale_name_code_page::cp_table_type::CodePage
) can be used as follows:
```rust use localenamecodepage::getcodepage;
fn main() { let encp = getcodepage("en-US").unwrap(); // prints "en-US locale: 1252 (ANSI) / 437 (OEM)" println!("en-US locale: {} (ANSI) / {} (OEM)", encp.ansi, encp.oem); } ```
https://web.archive.org/web/20180104073254/https://www.microsoft.com/resources/msdn/goglobal/default.mspx
Use the following libraries:
Combine with codepage and encoding_rs.
Use oem_cp.
Use locale_config.
You can use assets/nls_info.json
in your automatic code generation script.
MIT