Skip to main content

locale_default

Function locale_default 

Source
pub fn locale_default(locale: &str) -> &'static Encoding
Expand description

The fallback encoding a browser uses for a user whose language is locale (a BCP 47 tag such as ja, ru-RU or zh-Hant), from the HTML Standard’s table of suggested defaults. Pass it as Options::fallback when you know your users’ language, or a site’s.

use parsec_encoding::locale_default;
assert_eq!(locale_default("ja-JP"), encoding_rs::SHIFT_JIS);
assert_eq!(locale_default("zh-TW"), encoding_rs::BIG5);
assert_eq!(locale_default("en-GB"), encoding_rs::WINDOWS_1252);