pub fn parse_language_id(
lang_id: &str,
) -> Result<UnicodeLanguageIdentifier, ParserError>Expand description
Parse the given string as an Unicode Language Identifier.
This function parses according to unicode_language_id EBNF defined in UTS #35.
§Examples
use unicode_locale_parser::parse_language_id;
let res = parse_language_id("en-US").unwrap();
assert_eq!("en", res.language);
assert_eq!(None, res.script);
assert_eq!(Some("US".to_string()), res.region);
assert_eq!(None, res.variants);§Errors
This function returns an error in the following cases:
ParserError::Missingif the given language id is empty.ParserError::InvalidLanguageif the given language id is not a valid language identifier.ParserError::InvalidSubtagif the given language id is not a valid subtag.