Skip to content

API Overview

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

Enbrea.Bcp47 is split into a registry-independent core package and an optional IANA registry package.

Most applications interact primarily with LanguageTag, LanguageTagBuilder, LanguageRange, and the matching APIs. Enbrea.Bcp47.Iana adds registry validation and registry metadata access.

Enbrea.Bcp47

LanguageTag

Represents a parsed BCP 47 language tag.

Use it to:

  • parse and try-parse language tags
  • test well-formedness and structural validity
  • normalize language-tag strings
  • inspect normalized components
  • preserve the original input through Value
  • obtain the normalized representation through ToString()
  • compare tags by normalized value

Important properties include:

Value
Language
Extlangs
Script
Region
Variants
Extensions
PrivateUse
IsGrandfathered
IsPrivateUseOnly

Static convenience methods include:

LanguageTag.Parse(...)
LanguageTag.TryParse(...)
LanguageTag.IsWellFormed(...)
LanguageTag.IsStructurallyValid(...)
LanguageTag.Normalize(...)
LanguageTag.TryNormalize(...)

See Parsing and Validation and Normalization and Equality.

Bcp47Parser

Provides the underlying registry-independent RFC 5646 parser and normalizer.

Public operations include:

Bcp47Parser.Parse(...)
Bcp47Parser.TryParse(...)
Bcp47Parser.IsWellFormed(...)
Bcp47Parser.IsStructurallyValid(...)
Bcp47Parser.Normalize(...)
Bcp47Parser.TryNormalize(...)

Most application code can use the corresponding static methods on LanguageTag. Bcp47Parser remains useful when an explicit parser-oriented API is preferred.

LanguageTagBuilder

Provides fluent construction of language tags.

Component methods are:

.Language(...)
.Extlang(...)
.Script(...)
.Region(...)
.Variant(...)
.Extension(...)
.PrivateUse(...)
.Build()

Create a builder from an existing decomposable tag with:

LanguageTagBuilder.From(tag)

See Building Language Tags.

LanguageTagExtension

Represents one extension sequence in a parsed language tag.

Properties:

Singleton
Subtags

Instances are created by the parser rather than directly by application code.

LanguageRange

Represents a parsed RFC 4647 basic or extended language range.

Properties:

Value
Subtags
IsBasic
IsWildcard

ToString() returns the lowercase normalized range.

See Language Ranges.

LanguageRangeParser

Parses and validates language ranges.

Public operations:

LanguageRangeParser.Parse(...)
LanguageRangeParser.TryParse(...)
LanguageRangeParser.ParseBasic(...)
LanguageRangeParser.TryParseBasic(...)
LanguageRangeParser.IsBasic(...)
LanguageRangeParser.IsExtended(...)

Bcp47Matcher

Implements RFC 4647 matching.

Filtering:

Bcp47Matcher.BasicFilter(...)
Bcp47Matcher.ExtendedFilter(...)

Single-match checks:

Bcp47Matcher.IsBasicMatch(...)
Bcp47Matcher.IsExtendedMatch(...)

Lookup:

Bcp47Matcher.Lookup(...)

Filtering and Lookup have overloads for a single range and for a language priority list.

See Language Tag Matching.

LanguageRangeExtensions

Provides convenient single-range matching methods:

range.IsBasicMatch(tag)
range.IsExtendedMatch(tag)
range.BasicFilter(tags)
range.ExtendedFilter(tags)
range.Lookup(tags)

The static Bcp47Matcher API remains the natural choice for range priority lists.

Enbrea.Bcp47.Iana

IanaLanguageTagValidator

Adds registry-aware validation on top of the core parser.

Public operations:

IanaLanguageTagValidator.IsValid(...)
IanaLanguageTagValidator.Validate(...)
IanaLanguageTagValidator.IsDeprecated(...)

IsValid() and Validate() accept either a raw string or a parsed LanguageTag where applicable.

See IANA Validation.

LanguageTagExtensions

The IANA package adds convenience methods to parsed tags:

tag.IsIanaValid()
tag.ValidateIana()
tag.IsDeprecated()

IanaLanguageTagValidationResult

Represents a detailed IANA validation result.

Properties:

IsValid
Error
Subtag
SubtagType

A successful result is also available through:

IanaLanguageTagValidationResult.Success

IanaLanguageTagValidationError

Describes why IANA validation failed.

Available values:

None
StructurallyInvalid
UnregisteredGrandfatheredTag
UnregisteredLanguage
UnregisteredExtlang
UnregisteredScript
UnregisteredRegion
UnregisteredVariant

IanaLanguageSubtagRegistry

Provides direct access to the bundled registry snapshot.

Registry information includes:

  • membership by record type
  • snapshot file date
  • deprecation state
  • preferred values
  • language and extlang macrolanguages
  • language and extlang suppress-script values
  • extlang prefixes
  • variant prefixes
  • grandfathered and redundant complete tags

See IANA Registry.

IanaLanguageSubtagType

Identifies the registry record type:

Language
Extlang
Script
Region
Variant
Grandfathered
Redundant

Package boundaries

Use only Enbrea.Bcp47 when grammar, normalization, construction, ranges, and matching are sufficient.

Add Enbrea.Bcp47.Iana when application behavior depends on the bundled IANA registry snapshot.

This separation keeps the core parser deterministic and registry-independent while allowing applications to opt into registry-aware behavior explicitly.