BenBurgers.InternationalStandards.Iso 0.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package BenBurgers.InternationalStandards.Iso --version 0.3.0
NuGet\Install-Package BenBurgers.InternationalStandards.Iso -Version 0.3.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="BenBurgers.InternationalStandards.Iso" Version="0.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BenBurgers.InternationalStandards.Iso --version 0.3.0
#r "nuget: BenBurgers.InternationalStandards.Iso, 0.3.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.
// Install BenBurgers.InternationalStandards.Iso as a Cake Addin
#addin nuget:?package=BenBurgers.InternationalStandards.Iso&version=0.3.0

// Install BenBurgers.InternationalStandards.Iso as a Cake Tool
#tool nuget:?package=BenBurgers.InternationalStandards.Iso&version=0.3.0

Introduction

The collection of packages to which this package belongs contain codes, features and tools for standards of the International Organization for Standardization (ISO).

The International Organization for Standardization (ISO) is an international standard development organization composed of representatives from the national standards organizations of member countries. The organization develops and publishes standardization in all technical and nontechnical fields other than electrical and electronic engineering.[^1]

[^1]: Wikipedia, downloaded at 31 October 2022, 23:33 CET.

GitHub Sponsors

If you like my contributions, please have a look at my GitHub Sponsors profile. My open source contributions are available free of charge (but subject to licenses) and the contributions are made entirely in my free time, but sponsorship would be sincerely appreciated. Thank you.

Packages

Name Description
BenBurgers.InternationalStandards.Iso The main package with the codes and metadata.
BenBurgers.InternationalStandards.Iso.IO Features for reading Code Tables from authorities.
BenBurgers.InternationalStandards.Iso.Json Features for serializing and deserializing JSON.

BenBurgers.InternationalStandards.Iso

The currently supported ISO standards are:

Name Description
ISO 639 Language codes
ISO 3166 Country codes
ISO 4217 Currency codes

ISO 639

The ISO 639 standard defines language codes. The list of language codes may include "nl" (ISO 639-1) for Dutch / Flemish, or "ara" (ISO 639-3) for Arabic.

The ISO 639-1 (Part 1) code is a two-letter code.

The ISO 639-2T (Part 2, Terminological) code is a three-letter code.

The ISO 639-2B (Part 2, Bibliographic) code is a three-letter code.

The ISO 639-3 (Part 3) code is a three-letter code.

Example
var albanian = Iso639Code.Albanian;
var part1 = albanian.ToPart1(); // sq
var part2T = albanian.ToPart2(Iso639Part2Type.Terminological); // sqi
var part2B = albanian.ToPart2(Iso639Part2Type.Bibliographic); // alb
var part3 = albanian.ToPart3(); // alb

ISO 3166

The ISO 3166 standard defines country codes. The list of country codes may include AQ for Antarctica, or NL for the Netherlands.

The Alpha-2 code is a two-letter code as previously mentioned.

The Alpha-3 code is a three-letter code.

There is also a numeric code, which is unique for every country.

Example
using System.Globalization;
using BenBurgers.InternationalStandards.Iso.Iso3166;

var antarctica = Iso3166Code.Antarctica;
var alpha2 = antarctica.ToAlpha2(); // "AQ"
var alpha3 = antarctica.ToAlpha3(); // "ATA"
var numeric = (int)antarctica; // 010

var cultureInfo = new CultureInfo("fr");
var nameShort = antarctica.GetName(Iso3166NameVariant.Short, cultureInfo); // "Antarctique"
var nameLong = antarctica.GetName(Iso3166NameVariant.Long, cultureInfo); // "Antarctique"

var fromString2 = "AQ".ToIso3166(); // Iso3166Code.Antarctica
var fromString3 = "ATA".ToIso3166(); // Iso3166Code.Antarctica

ISO 4217

The ISO 4217 standard defines currency codes. The list of currency codes may include EUR for Euro, or USD for US Dollar.

The code can be expressed by an Alpha-3 three-letter code or a numeric code.

Example
using BenBurgers.InternationalStandards.Iso.Iso4217;

var usDollar = Iso4217Code.USDollar;
var alpha = usDollar.ToAlpha(); // "USD"
var entities = string.Join(", ", usDollar.GetEntities()); // AMERICAN SAMOA, BONAIRE, SINT EUSTATIUS AND SABA, BRITISH INDIAN OCEAN TERRITORY (THE), ECUADOR, EL SALVADOR, GUAM, HAITI, MARSHALL ISLANDS (THE), MICRONESIA (FEDERATED STATES OF), NORTHERN MARIANA ISLANDS (THE), PALAU, PANAMA, PUERTO RICO, TIMOR-LESTE, TURKS AND CAICOS ISLANDS (THE), UNITED STATES MINOR OUTLYING ISLANDS (THE), UNITED STATES OF AMERICA (THE), VIRGIN ISLANDS (BRITISH), VIRGIN ISLANDS (U.S.)
var referenceName = usDollar.GetReferenceName(); // US Dollar
var minorUnits = usDollar.GetMinorUnits(); // 2
var numeric = (int)usDollar; // 840

BenBurgers.InternationalStandards.Iso.Json

The BenBurgers.InternationalStandards.Iso.Json package contains features for serializing and deserializing to and from JSON using the ISO standards. The package provides, among other features, JSON converters that may be added to the serialization options in order to control the serialization and deserialization of ISO compliant data.

ISO 639

There are JSON Converters for ISO 639 from and to the ISO 639-1, ISO 639-2T, ISO 639-2B and ISO 639-3 codes. The converters can be used directly, like in the example below, or in the JSON serializer from System.Text.Json.

Example
const Iso639Code Value = Iso639Code.Albanian;
var options = new Iso639JsonConverterOptions(Iso639AlphaMode.Part2T);
var jsonConverter = new Iso639AlphaJsonConverter(options);
using var stream = new MemoryStream();
using var utf8JsonWriter = new Utf8JsonWriter(stream);

utf8JsonWriter.WriteStartObject();
utf8JsonWriter.WritePropertyName("Albanian");
jsonConverter.Write(utf8JsonWriter, Value, new JsonSerializerOptions());
utf8JsonWriter.WriteEndObject();
utf8JsonWriter.Flush();

/*
* The result will be:
*
* {"Albanian":"sqi"}
*/

ISO 3166

There are JSON Converters for ISO 3166 from and to the alpha-2 and alpha-3 codes as well as the numeric code. The converters can be used directly, like in the example below, or in the JSON serializer from System.Text.Json.

Example
using BenBurgers.InternationalStandards.Iso.Iso3166;
using BenBurgers.InternationalStandards.Iso.Json.Iso3166.Alpha;
using System.Text.Json;

const Iso3166Code Value = Iso3166Code.Antarctica;
var options = new Iso3166JsonConverterOptions(Iso3166AlphaMode.Alpha2);
var jsonConverter = new Iso3166AlphaJsonConverter(options);
using var stream = new MemoryStream();
using var writer = new Utf8JsonWriter(stream);

writer.WriteStartObject();
writer.WritePropertyName("Antarctica");
jsonConverter.Write(writer, Value, new JsonSerializerOptions());
writer.WriteEndObject();
writer.Flush();

/*
* The result will be:
*
* {"Antarctica":"AQ"}
*/

ISO 4217

There are JSON Converters for ISO 4217 from and to the alpha-3 codes as well as the numeric code. The converters can be used directly or in the JSON serializer from System.Text.Json.

Example
using BenBurgers.InternationalStandards.Iso.Iso4217;
using BenBurgers.InternationalStandards.Iso.Json.Iso4217.Alpha;
using System.Text.Json;

const Iso4217Code Value = Iso4217Code.Euro;
var options = new Iso4217JsonConverterOptions();
var jsonConverter = new Iso4217AlphaJsonConverter(options);
using var stream = new MemoryStream();
using var writer = new Utf8JsonWriter(stream);

writer.WriteStartObject();
writer.WritePropertyName("Currency");
jsonConverter.Write(writer, Value, new JsonSerializerOptions());
writer.WriteEndObject();
writer.Flush();

/*
* The result will be:
*
* {"Currency":"EUR"}
*/

Supported Languages

The supported languages in the ISO packages are:

ISO 639-1 Name
neutral
en English
fr French
nl Dutch

More may be added in the future.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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 is compatible.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on BenBurgers.InternationalStandards.Iso:

Package Downloads
BenBurgers.InternationalStandards.Iso.Json

JSON features for international standards as adopted by the International Organization for Standardization (ISO). This may include country codes, language codes and more.

BenBurgers.InternationalStandards.Iso.IO

Input/Output for international standards as adopted by the International Organization for Standardization (ISO). This may include country codes, language codes and more.

BenBurgers.InternationalStandards.Iso.EFCore

Entity Framework Core (SQL Server) features for international standards as adopted by the International Organization for Standardization (ISO). This may include country codes, language codes, currency codes and more.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.0 267 12/5/2023
0.4.0 535 1/3/2023
0.3.0 731 11/15/2022
0.2.0 512 11/9/2022
0.1.0 453 11/4/2022

Version 0.3.0
- ISO 639: Fixed bug; if an unassigned Part of ISO 639 was requested, an exception was thrown that said it was deprecated.
- ISO 639: Implemented stub for conversion from string to ISO 639 code.
- ISO 3166: Improved documentation.
- ISO 4217: Added ISO 4217 currency codes.
- ISO 4217/IO: Added ISO 4217 Input/Output for importing currency codes from authority.
- ISO 4217/JSON: Added ISO 4217 (de)serialization.
Version 0.2.0
- ISO 639: Added ISO 639 language codes.
- ISO 639/IO: Added ISO 639 Input/Output for importing Code Tables from authority.
- ISO 639/JSON: Added ISO 639 (de)serialization.
- ISO 3166/JSON: Support for reading (in addition to writing) ISO 3166 numeric code as string.
- Added support for .NET 7.0 .
Version 0.1.0
- ISO 3166: Added ISO 3166 country codes.
- ISO 3166/JSON: Added ISO 3166 (de)serialization.