Skip to content

IANA Registry

Frank Stüber edited this page Sep 11, 2026 · 2 revisions

Enbrea.Bcp47.Iana contains a bundled snapshot of the IANA Language Subtag Registry.

The registry is compiled into the package as generated compact lookup data. No network access or runtime CSV parsing is required. The public access API is IanaLanguageSubtagRegistry.

Registry snapshot date

The source registry's file date is available through FileDate:

DateOnly date = IanaLanguageSubtagRegistry.FileDate;

This identifies the registry snapshot from which the bundled lookup data was generated.

Registry entry types

IanaLanguageSubtagType defines the supported registry record types:

Language
Extlang
Script
Region
Variant
Grandfathered
Redundant

These correspond to either registered subtags or complete registered tags.

Checking language subtags

Use ContainsLanguage():

bool registered = IanaLanguageSubtagRegistry.ContainsLanguage("de");

The method also recognizes the RFC/IANA reserved private-use language range qaa through qtz:

IanaLanguageSubtagRegistry.ContainsLanguage("qaa"); // true

Registry range expressions themselves are storage notation and are not treated as actual subtags.

Checking scripts

bool registered = IanaLanguageSubtagRegistry.ContainsScript("Latn");

The reserved private-use script range Qaaa through Qabx is also accepted for use as a script subtag.

Checking regions

bool registered = IanaLanguageSubtagRegistry.ContainsRegion("DE");

The reserved region ranges QM through QZ and XA through XZ are also recognized.

Other membership checks

Dedicated methods are available for the other registry types:

IanaLanguageSubtagRegistry.ContainsExtlang("cmn");
IanaLanguageSubtagRegistry.ContainsVariant("1901");
IanaLanguageSubtagRegistry.ContainsGrandfatheredTag("i-klingon");
IanaLanguageSubtagRegistry.ContainsRedundantTag("zh-cmn");

A generic API is also available:

bool result = IanaLanguageSubtagRegistry.Contains(
    IanaLanguageSubtagType.Language,
    "de");

Deprecated entries

Use IsDeprecated() with a registry type:

bool deprecated = IanaLanguageSubtagRegistry.IsDeprecated(
    IanaLanguageSubtagType.Language,
    "iw");

A deprecated entry remains a registry entry. Deprecation therefore does not imply that Contains() returns false.

Preferred values

Some deprecated or legacy records define a Preferred-Value.

Use TryGetPreferredValue():

if (IanaLanguageSubtagRegistry.TryGetPreferredValue(
    IanaLanguageSubtagType.Language,
    "iw",
    out var preferred))
{
    Console.WriteLine(preferred);
}

The core package does not automatically apply these mappings during normalization. Core normalization is registry-independent. See Normalization and Equality.

Variant prefixes

Variants can define one or more registry prefixes.

Use GetVariantPrefixes():

var prefixes = IanaLanguageSubtagRegistry.GetVariantPrefixes("rozaj");

foreach (var prefix in prefixes)
{
    Console.WriteLine(prefix);
}

If the variant has no registered prefixes, an empty list is returned.

Extlang prefix

The prefix associated with an extlang can be queried with:

if (IanaLanguageSubtagRegistry.TryGetExtlangPrefix(
    "cmn",
    out var prefix))
{
    Console.WriteLine(prefix);
}

The validator exposes registry membership independently of prefix guidance. See IANA Validation.

Suppress-Script

Languages can define a Suppress-Script value:

if (IanaLanguageSubtagRegistry.TryGetLanguageSuppressScript(
    "de",
    out var script))
{
    Console.WriteLine(script);
}

Extlangs can be queried separately:

IanaLanguageSubtagRegistry.TryGetExtlangSuppressScript(
    "cmn",
    out var script);

Suppress-Script is metadata. The core normalizer does not remove scripts based on this field.

Macrolanguages

Language and extlang records can expose macrolanguage relationships:

IanaLanguageSubtagRegistry.TryGetLanguageMacrolanguage(
    language,
    out var macrolanguage);

For extlangs:

IanaLanguageSubtagRegistry.TryGetExtlangMacrolanguage(
    extlang,
    out var macrolanguage);

Complete tags

Most IANA registry entries describe individual subtags. Two registry types describe complete tags instead:

  • grandfathered tags
  • redundant tags

These are queried with:

IanaLanguageSubtagRegistry.ContainsGrandfatheredTag(value);
IanaLanguageSubtagRegistry.ContainsRedundantTag(value);

Their deprecation and preferred-value metadata can be queried through the same generic APIs by using IanaLanguageSubtagType.Grandfathered or IanaLanguageSubtagType.Redundant.

Bundled data and updates

The package does not download registry data at runtime. Its generated lookup tables represent a specific registry snapshot.

Applications that need to know the snapshot age can inspect:

IanaLanguageSubtagRegistry.FileDate

Updating the NuGet package to a release containing a newer generated snapshot updates the registry data used by the application.

Clone this wiki locally