Locale.fromString constructor
- String name
Construct an Locale from an locale identifier.
This will run the complete locale parsing algorithm. If code size and
performance are critical and the locale is of a known shape (such as
aa-BB
) use create_und
, set_language
, set_script
, and set_region
.
See the Rust documentation for try_from_str
for more information.
Throws LocaleParseError on failure.
Implementation
factory Locale.fromString(String name) {
final temp = _FinalizedArena();
final result = _icu4x_Locale_from_string_mv1(name._utf8AllocIn(temp.arena));
if (!result.isOk) {
throw LocaleParseError.values[result.union.err];
}
return Locale._fromFfi(result.union.ok, []);
}