DataStandardizer.LanguageTag 1.2.0

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package DataStandardizer.LanguageTag --version 1.2.0
                    
NuGet\Install-Package DataStandardizer.LanguageTag -Version 1.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DataStandardizer.LanguageTag" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DataStandardizer.LanguageTag" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="DataStandardizer.LanguageTag" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DataStandardizer.LanguageTag --version 1.2.0
                    
#r "nuget: DataStandardizer.LanguageTag, 1.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DataStandardizer.LanguageTag@1.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DataStandardizer.LanguageTag&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=DataStandardizer.LanguageTag&version=1.2.0
                    
Install as a Cake Tool

Introduction

Data Standardizer provides implementations of various internationally recognised standards in data processing, covering topics ranging from languages to currencies and geographical entities. With strongly-typed enumerations for each standard (where applicable) or other targeted data types, you can represent these elements in your code such that errors with invalid values are minimised.

Supported target platforms include (modern) .Net and .Net Standard. Data Standardizer can be used in modern application software, but is also available as an option for older codebases that are being upgraded more gradually or may remain on older frameworks indefinitely.

📚 Documentation

Full documentation — user guides, concepts, and API reference for every package — is published at matthew25187.github.io/DataStandardizer.

Supporting the project

If you derive a commercial benefit from use of Data Standardizer or feel it otherwise adds value to your project, you are asked to please consider supporting the project. You can do this by becoming a GitHub sponsor to make a financial contribution. Data Standardizer is maintained and enhanced by @matthew25187 in his personal time and made available for free for all to use.

Getting Started

Installation

Data Standardizer is available as a series of packages from NuGet.org that can be linked to your existing projects. Available packages include:

Package Description
DataStandardizer.Chronology Supports the following standards:<ul><li>TZ Database</li><li>Unix time</li><li>DOS date & time</li></ul>
DataStandardizer.Communication Supports the following standards:<ul><li>Recommendation ITU-T E.164, The international public telecommunication numbering plan</li></ul>
DataStandardizer.Core Common types used to implement standards in the other packages. You should not need to link to this package directly.
DataStandardizer.File.CSV Supports the following standards:<ul><li>RFC 4180, Common Format and MIME Type for Comma-Separated Values (CSV) Files</li></ul>
DataStandardizer.File.iCal Supports the following standards:<ul><li>RFC 5545, Internet Calendaring and Scheduling Core Object Specification (iCalendar)</li><li>RFC 6868, Parameter Value Encoding in iCalendar and vCard</li><li>RFC 7986, New Properties for iCalendar</li><li>RFC 7265, jCal: The JSON Format for iCalendar</li><li>RFC 6321, xCal: The XML Format for iCalendar</li></ul>
DataStandardizer.Geography Supports the following standards:<ul><li>ISO 3166-1, Codes for the representation of names of countries and their subdivisions – Part 1: Country code</li><li>ISO 3166-2, Codes for the representation of names of countries and their subdivisions – Part 2: Country subdivision code</li><li>UN M49, Standard Country or Area Codes for Statistical Use (Series M, No. 49)</li></ul>
DataStandardizer.Language Supports the following standards:<ul><li>ISO 639, Code for the representation of names of languages</li><ul><li>Part 1: Alpha-2 code</li><li>Part 2: Alpha-3 code</li><li>Part 3: Alpha-3 code for comprehensive coverage of languages</li><li>Part 5: Alpha-3 code for language families and groups</li></ul><li>ISO 15924, Codes for the representation of names of scripts</li></ul>
DataStandardizer.LanguageTag Supports the following standards:<ul><li>IETF BCP 47 language tags, as defined by:<ul><li>RFC 5646, Tags for Identifying Languages, including the IANA Language Subtag Registry format</li></ul></li></ul>
DataStandardizer.Money Supports the following standards:<ul><li>ISO 4217, Codes for the representation of currencies and funds</li><ul><li>Table A.1 – Current currency & funds code list</li><li>Table A.2 – Current funds codes</li><li>Table A.3 – List of codes for historic denominations of currencies & funds</li></ul><li>Money type, as described in Patterns of Enterprise Application Architecture by Martin Fowler</li></ul>

To use a particular standard in your application, find the corresponding package from the above list and add it as a dependency to your project. Instructions for doing so will depend on what development tooling you are using.

See the Get started guide for step-by-step installation and a quickstart.

Software dependencies

Depending on which .Net platform you are targeting, the above packages will also depend on various other system- and third-party packages. They will be included as static dependencies where required and should be automatically resolved, but if you are using a proxy for your package server you may need to make sure these other packages are also available. For example, the netstandard2.0 build of DataStandardizer.LanguageTag depends on System.Memory for its span-based API.

Latest releases

Package Release version Release status
DataStandardizer.Chronology DataStandardizer.Chronology package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.Communication DataStandardizer.Communication package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.Core DataStandardizer.Core package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.File.CSV DataStandardizer.File.CSV package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.File.iCal DataStandardizer.File.iCal package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.Geography DataStandardizer.Geography package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.Language DataStandardizer.Language package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.LanguageTag DataStandardizer.LanguageTag package in DataStandardizer@Release feed in Azure Artifacts Build Status
DataStandardizer.Money DataStandardizer.Money package in DataStandardizer@Release feed in Azure Artifacts Build Status

The most recently produced release version (shown above) does not necessarily correspond with the latest package version published to NuGet or any other publically available source.

Build and test

Data Standardizer is open source so you can read, build, and adapt it for your own use. The project does not currently accept third-party code contributions; the instructions below are provided as a convenience for working with your own copy or fork of the repository.

After cloning the repository, you can compile the entire solution from the repository root:

dotnet build DataStandardizer.sln

and run the XUnit-based tests with:

dotnet test DataStandardizer.sln

Per-package solution filter (*.slnf) files let you build or test a single package in isolation. For the full branching strategy, per-package builds, IDE testing, and the PowerShell scripts that regenerate the standard enums, see Build from source in the documentation.

Usage

Though each package contains many types, typically there are only a few you will use directly in your application. See the project documentation for user guides, concepts, and API reference covering each package — including built-in CSV reading, writing, and normalization in DataStandardizer.File.CSV, and iCalendar reading, writing, and recurrence expansion in DataStandardizer.File.iCal.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on DataStandardizer.LanguageTag:

Package Downloads
DataStandardizer.Money

Data Standardizer provides implementations of various internationally recognised standards in data processing, covering topics ranging from languages to currencies and geographical entities. With strongly-typed enumerations for each standard (where applicable) or other targeted data types, you can represent these elements in your code such that errors with invalid values are minimised. Includes: - Supports use of ISO 4217, "Codes for the representation of currencies and funds" - Table A.1 – Current currency & funds code list - Table A.3 – List of codes for historic denominations of currencies & funds - Money data type as described in "Patterns of Enterprise Application Architecture" by Martin Fowler. Combines an amount with an ISO 4217 currency code to manage a monetary value. - Culture-specific currency formatting, and the currency of each region, from the Unicode Common Locale Data Repository (CLDR).

DataStandardizer.Communication

Data Standardizer provides implementations of various internationally recognised standards in data processing, covering topics ranging from languages to currencies and geographical entities. With strongly-typed enumerations for each standard (where applicable) or other targeted data types, you can represent these elements in your code such that errors with invalid values are minimised. Provides types supporting communication-related standards, including: - ITU-T E.164 telephony numbers - MIME: media types, transfer encodings, base64 and quoted-printable codecs, character sets, data: URIs, encoded words and RFC 2231 parameter values

DataStandardizer.File.vCard

Data Standardizer provides implementations of various internationally recognised standards in data processing, covering topics ranging from languages to currencies and geographical entities. With strongly-typed enumerations for each standard (where applicable) or other targeted data types, you can represent these elements in your code such that errors with invalid values are minimised. Provides types supporting the reading and writing of vCard files. Includes: - vCard Format Specification, RFC 6350 (content lines, value types, the card object model, and reading and writing cards with conformance checks) - Parameter Value Encoding in iCalendar and vCard, RFC 6868 - jCard: The JSON Format for vCard, RFC 7095 (reading and writing cards as JSON, on .NET Standard 2.0 and later) - xCard: vCard XML Representation, RFC 6351 (reading and writing cards as XML) - vCard 2.1 (reading and writing vCard 2.1 cards, with quoted-printable, BASE64, CHARSET, parameters with no name and the card an AGENT holds) - vCard MIME Directory Profile, RFC 2426, and MIME Content-Type for Directory Information, RFC 2425 (reading and writing vCard 3.0 cards, and converting between versions) - Calendar Attributes for vCard and LDAP, RFC 2739 - vCard Extensions for Instant Messaging, RFC 4770 - vCard Format Extensions for JSContact, RFC 9554 - vCard KIND:application, RFC 6473, and vCard KIND:device, RFC 6869 - vCard Format Extensions: Place of Birth, Place and Date of Death, RFC 6474 - vCard Format Extensions: Representing vCard Extensions Defined by the Open Mobile Alliance (OMA) Converged Address Book (CAB) Group, RFC 6715 - vCard Format Extensions: ICANN Extensions for the Registration Data Access Protocol, RFC 8605

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 328 11/10/2026
1.3.0-preview.1 65 11/6/2026
1.2.0 126 10/23/2026
1.1.0 5,513 1/10/2026
1.0.0 324 12/7/2025 1.0.0 is deprecated because it has critical bugs.
1.0.0-preview.3 168 12/6/2025
1.0.0-preview.1 217 9/25/2025

New:
- `Bcp47LanguageTagBuilder.UsingRegionSubtag(UnM49Area)` sets a UN M.49 area such as `UnM49Area._419` (Latin America and the Caribbean) as the region, and throws `ArgumentException` for a country.
- On .NET 10, `UsingVariantSubtags` and `UsingExtensionSubtags` have `params ReadOnlySpan<string>` overloads, so passing several subtags doesn't allocate an array for them.
- `SubtagRegistry.CreateFromContentAsync`, `CreateFromStreamAsync` and `CreateFromFileAsync` have overloads that take a `CancellationToken`, and throw `OperationCanceledException` when it is cancelled.
- On netstandard2.0 and .NET 8 and later, `Bcp47LanguageTag.TryCreate`, `IsWellFormedLanguageTagString` and the `Check*` methods accept a `ReadOnlySpan<char>`; only `TryCreate` allocates, and only to copy a valid tag to a string. `AsSpan()` returns the tag without copying it.
- `Bcp47LanguageTag` implements `IParsable<T>` and `ISpanParsable<T>` on .NET 7 and later, and `ISpanFormattable` on .NET 6 and later.

Fixed:
- Bcp47LanguageTag tags that differ only in case have equal hash codes.
- `Bcp47LanguageTag.ToIso3166Part1Alpha2()` returns `null` for a UN M.49 region such as `es-419` instead of an undefined `Iso3166Part1Alpha2Country` value.
- `SubtagRegistry.CreateFromStream` and `CreateFromStreamAsync` no longer dispose the caller's stream.
- `SubtagRegistrySubtagRecord` and `SubtagRegistryTagRecord` now return the registry's `Added`, `Deprecated`, `PreferredValue` and `SuppressScript` values instead of defaults.
- A language tag that repeats a variant subtag or an extension singleton, ignoring case, is rejected as RFC 5646 requires, by `Create`, `TryCreate`, `IsWellFormedLanguageTagString` and the builder's `UsingVariantSubtags` and `UsingExtensionSubtags`.
- Without a subtag registry, the irregular grandfathered tags, such as `i-klingon` and `en-GB-oed`, are accepted as RFC 5646 requires.
- Without a subtag registry, primary language subtags follow RFC 5646: one of five to eight characters must be letters only, so `12345` is rejected, and an extended language subtag must follow one of two or three letters, so `abcde-yue` is rejected.
- Without a subtag registry, the region subtag `830` (Channel Islands), which isn't in the IANA Language Subtag Registry, is rejected as RFC 5646 requires.
- Create and TryCreate with a Subtag Registry accept subtags in the registry's ranges, such as qaa, en-Qaaa, en-QM and en-XA.
- Bcp47KeyedSubtag equality and GetHashCode ignore case, as Bcp47LanguageTag equality does, so the extension subtags of en-u-co and en-U-CO are equal.
- The explicit conversion from `string` to `Bcp47LanguageTag` now validates the tag and throws `InvalidCastException` for `null` or a tag that is not well-formed, instead of returning an unusable instance.
- TryCreate overloads with a matchTimeout return false when matching times out.
- `TryCreate(string, SubtagRegistry, TimeSpan, out Bcp47LanguageTag)` accepts tags that are valid only in the Subtag Registry, as the other registry overloads do.
- `Create`, `TryCreate`, `IsWellFormedLanguageTagString` and the `Check*Subtag` methods no longer accept a language tag or subtag followed by a line feed.
- Language tag and subtag validation no longer depends on the current culture or accepts non-ASCII letters, so `IT` is accepted under the Turkish culture and the Kelvin sign (U+212A) is not accepted in place of `K`.
- Creating language tags against the same Subtag Registry from several threads at once no longer throws or corrupts a shared cache.
- A Subtag Registry with no grandfathered records, or no records of some subtag type, no longer accepts the empty string or a tag with an empty subtag such as "en-".
- A `null` or invalid subtag among the later arguments of `UsingVariantSubtags` or `UsingExtensionSubtags` throws with `ParamName` `variantSubtags` or `extensionSubtags`, not `input` or `invalidSubtag`.
- `Bcp47LanguageTag`'s static `Check*Subtag` methods and `IsWellFormedLanguageTagString` throw `ArgumentNullException` naming their own parameter for `null`, not `input`.
- Loading a Subtag Registry unfolds a folded Description or Comments value with one space, skips an empty record or one with no File-Date, Subtag or Tag field instead of stopping there, and reads a field it doesn't know as a field of its own instead of appending it to the field before.
- Bcp47LanguageTag accepts the private use script subtags Qaay and Qaaz without a subtag registry.

Deprecated and removed:
- The builder's `UsingRegionSubtag(UnM49AreaByAlpha2CountryCode)` and `UsingRegionSubtag(UnM49AreaByAlpha3CountryCode)` overloads are obsolete, because they reject every member of those enums, and will be removed in v2.0; use `UsingRegionSubtag(UnM49Area)` or `UsingRegionSubtag(Iso3166Part1Alpha2Country)`.
- The matchTimeout overloads of Bcp47LanguageTag.Create and TryCreate, and Bcp47LanguageTagBuilder.WithTimeout, are obsolete: the timeout has no effect, and they will be removed in version 2.0.

Changed:
- `SubtagRegistry.CreateFromStream` and `CreateFromStreamAsync` read from the stream's current position instead of rewinding it to the start.
- Without a subtag registry, regular grandfathered tags such as `art-lojban` are treated as whole tags, as they are with one: `PrimaryLanguageSubtag` is empty and the other subtag properties are `null` or empty.
- Without a subtag registry, four-letter primary language subtags, which RFC 5646 reserves for future use, are accepted as well-formed.
- Validation by the default BCP 47 rules uses a parser instead of regular expressions: the first Create is about 20 times faster, later calls 30 to 300 times faster, and validation no longer allocates.
- The netstandard2.0 build depends on System.Memory.
- Reading the subtag properties of a `Bcp47LanguageTag` no longer parses the language tag again, and `ToUnM49()` no longer reads the UN M.49 codes on every call.
- Checking a language tag against a Subtag Registry uses a parser instead of regular expressions: Create is about 10,000 times faster, the first call in a process takes milliseconds instead of more than a second, and checking no longer allocates.
- `Bcp47KeyedSubtag.Singleton` no longer allocates, and `Subtags` allocates only the array it returns.
- Building a language tag with `Bcp47LanguageTagBuilder` allocates less and no longer reflects over the UN M.49 enums on every `UsingRegionSubtag` call.
- Converting a `null` string to `Bcp47KeyedSubtag` throws `InvalidCastException`, like `Bcp47LanguageTag`, instead of `ArgumentNullException`.
- Reading the properties of a Subtag Registry record, such as `Added` and `Description`, is about 14 times faster and allocates 98% less.
- `Added`, `Deprecated` and `FileDate` read a registry date only in the RFC 5646 form `yyyy-MM-dd`, and throw `FormatException` for any other form.
- Loading a Subtag Registry is about 2.3 times faster and allocates 73% less.
- The `SubtagRegistry` async loaders no longer resume on the caller's synchronization context, and `CreateFromFileAsync` reads the file with asynchronous I/O.
- The new span overloads make a literal `null` or `default` argument to `TryCreate`, `IsWellFormedLanguageTagString` or a `Check*` method ambiguous on C# 7.3; cast it to `string`. On C# 10 and later, `IsWellFormedLanguageTagString` and the `Check*` methods can no longer be assigned to `var`; give the variable a delegate type such as `Func<string, bool>`. `Type.GetMethod(name)` throws `AmbiguousMatchException` for them; pass the parameter types. Compiled code is unaffected.
- On .NET 10, `Bcp47LanguageTag.Create`, `TryCreate`, `IsWellFormedLanguageTagString` and the `Check*Subtag` methods are about twice as fast, with or without a Subtag Registry.
- The first validation against a newly loaded `SubtagRegistry` is faster on every target, about 2.6 times as fast on .NET 10.