Skip to content

Wrong locale evaluation on Unix-like systems without codeset but with modifier #32

@pasabanov

Description

@pasabanov

According to this specification, the POSIX locale is defined as:

language[_territory][.codeset][@modifier]

For example, the locale De_DE@dict is valid.

However, the current implementation of the library does not check for the @ character, leading to an invalid locale detection when the codeset is not present but the modifier is.

Example:

let fr_FR_euro = "fr_FR@euro".to_owned();
let mut env = MockEnv::new();
env.insert("LANGUAGE".into(), fr_FR_euro);
env.insert("LC_ALL".into(), fr_FR_euro);
env.insert("LC_MESSAGES".into(), fr_FR_euro);
env.insert("LANG".into(), fr_FR_euro);
env.insert("LC_CTYPE".into(), fr_FR_euro);
let locale = _get(&env);
// locale is equal to "fr-FR@euro" which is not a valid BCP 47 locale

The simplest possible solution would be:

However, since some POSIX modifiers might be convertible to BCP 47, a more complex solution would be:

  • Implement full support for POSIX modifiers, meaning the library would use the modifier information to form the resulting BCP 47 locale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions