BCP 47 language tag validation utilities. More...
Functions | |
| SOURCEMETA_CORE_LANGTAG_EXPORT auto | sourcemeta::core::is_langtag (const std::string_view value) -> bool |
| SOURCEMETA_CORE_LANGTAG_EXPORT auto | sourcemeta::core::is_canonical_langtag (const std::string_view value) -> bool |
| SOURCEMETA_CORE_LANGTAG_EXPORT auto | sourcemeta::core::langtag_equals (const std::string_view left, const std::string_view right) -> bool |
BCP 47 language tag validation utilities.
This functionality is included as follows:
| SOURCEMETA_CORE_LANGTAG_EXPORT auto sourcemeta::core::is_canonical_langtag | ( | const std::string_view | value | ) | -> bool |
Check whether the given string is a well-formed language tag per RFC 5646 (BCP 47) that also follows the recommended casing conventions of RFC 5646 Section 2.1.1: script subtags in titlecase, region subtags in uppercase, and every other subtag, including every subtag after a singleton, in lowercase. The deprecated irregular grandfathered tags are rejected, as the registry maps each of them to a canonical replacement. For example:
| SOURCEMETA_CORE_LANGTAG_EXPORT auto sourcemeta::core::is_langtag | ( | const std::string_view | value | ) | -> bool |
Check whether the given string is a well-formed language tag per RFC 5646 (BCP 47). In addition to the grammar, the two duplication errors that the specification forbids without consulting any registry are rejected: a repeated variant subtag (RFC 5646 Section 2.2.5) and more than one extension for the same singleton (RFC 5646 Section 2.2.6). Validity against the IANA Language Subtag Registry is not checked, so a structurally well-formed tag whose subtags are not registered is still accepted. Comparison is case-insensitive, as language tags are. For example:
| SOURCEMETA_CORE_LANGTAG_EXPORT auto sourcemeta::core::langtag_equals | ( | const std::string_view | left, |
| const std::string_view | right ) -> bool |
Check whether two language tags are equal per RFC 5646 (BCP 47) Section 2.1.1, which treats tags and their subtags as case insensitive. The comparison is allocation-free and does not validate its arguments. For example: