ADRaffy.ENSNormalize 0.1.2

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

// Install ADRaffy.ENSNormalize as a Cake Tool
#tool nuget:?package=ADRaffy.ENSNormalize&version=0.1.2                

ENSNormalize.cs

0-dependency ENSIP-15 in C#

NuGet version

using ADRaffy.ENSNormalize;
ENSNormalize.ENSIP15 // Main Library (global instance)

Primary API ENSIP15

// string -> string
// throws on invalid names
ENSNormalize.ENSIP15.Normalize("RaFFY🚴‍♂️.eTh"); // "raffy🚴‍♂.eth"

// works like Normalize()
ENSNormalize.ENSIP15.Beautify("1⃣2⃣.eth"); // "1️⃣2️⃣.eth"

Output-based Tokenization Label

// string -> Label[]
// never throws
Label[] labels = ENSNormalize.ENSIP15.Split("💩Raffy.eth_");
// [
//   Label {
//     Input: [ 128169, 82, 97, 102, 102, 121 ],  
//     Tokens: [
//       OutputToken { Codepoints: [ 128169 ], IsEmoji: true }
//       OutputToken { Codepoints: [ 114, 97, 102, 102, 121 ] }
//     ],
//     Normalized: [ 128169, 114, 97, 102, 102, 121 ],
//     Group: Group { Name: "Latin", ... }
//   },
//   Label {
//     Input: [ 101, 116, 104, 95 ],
//     Tokens: [ 
//       OutputToken { Codepoints: [ 101, 116, 104, 95 ] }
//     ],
//     Error: NormError { Kind: "underscore allowed only at start" }
//   }
// ]

// string -> Label
// never throws
Label label = ENSNormalize.ENSIP15.NormalizeLabel("ABC");
// note: this throws on "."

Normalization Properties

  • GroupENSIP15.Groups: IReadOnlyList<Group>
  • EmojiSequenceENSIP15.Emojis: IReadOnlyList<EmojiSequence>
  • WholeENSIP15.Wholes: IReadOnlyList<Whole>

Error Handling

All errors are safe to print. Functions that accept names as input wrap their exceptions in InvalidLabelException for additional context.

Errors with Additional Context
Error Kinds
  • "empty label"
  • "duplicate non-spacing marks"
  • "excessive non-spacing marks"
  • "leading fenced"
  • "adjacent fenced"
  • "trailing fenced"
  • "leading combining mark"
  • "emoji + combining mark"
  • "invalid label extension"
  • "underscore allowed only at start"
  • "illegal mixture"
  • "whole-script confusable"
  • "disallowed character"

Utilities

Normalize name fragments for substring search:

// string -> string
// only throws InvalidLabelException w/DisallowedCharacterException
ENSIP15.NormalizeFragment("AB--");
ENSIP15.NormalizeFragment("..\u0300");
ENSIP15.NormalizeFragment("\u03BF\u043E");
// note: Normalize() throws on these

Construct safe strings:

// int -> string
ENSIP15.SafeCodepoint(0x303); // "◌̃"
// IReadOnlyList<int> -> string
ENSIP15.SafeImplode(new int[]{ 0x303, 0xFE0F }); // "◌̃{FE0F}"

Determine if a character shouldn't be printed directly:

// IReadOnlyCollection<int>
ENSIP15.ShouldEscape.Contains(0x202E); // RIGHT-TO-LEFT OVERRIDE => true

Determine if a character is a combining mark:

// IReadOnlyCollection<int>
ENSNormalize.ENSIP15.CombiningMarks.Contains(0x20E3); // COMBINING ENCLOSING KEYCAP => true

Unicode Normalization Forms NF

using ADRaffy.ENSNormalize;

// string -> string 
// IEnumerable<int> -> int[]
ENSNormalize.NF.NFC("\x65\u0300"); // [E5]
ENSNormalize.NF.NFD("\xE5"); // [65 300]
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 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. 
.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 is compatible. 
.NET Standard netstandard1.1 is compatible.  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 is compatible.  net452 was computed.  net46 was computed.  net461 is compatible.  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 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.
  • .NETCoreApp 3.1

    • No dependencies.
  • .NETFramework 4.5.1

    • No dependencies.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETStandard 1.1

  • .NETStandard 2.0

    • No dependencies.
  • net5.0

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on ADRaffy.ENSNormalize:

Package Downloads
Nethereum.Contracts

Nethereum Contracts is the core library to interact via RPC with Smart contracts in Ethereum

Nethereum.Fx

Nethereum Fx, a single package combining most of the main Nethereum libraries (Web3, ABI, Contracts, Accounts, Signers, RPC, WebSockets, IPC, RLP, HdWallet, Geth, Parity, Besu, Quorum, KeyStore, etc) and targetting: net5.0,netcoreapp3.1,netstandard2.0 and netstandard2.1

Nethereum.LiteFx

Nethereum Fx Lite, a single package that combining a small set of Nethereum libraries (for simple portability) not including crypto dependencies to be used with external signers (Web3, ABI, Contracts, RPC, RLP, ENS, ERC20, ERC721) and targetting: net5.0,netcoreapp3.1,netstandard2.0 and netstandard2.1

NethereumQuantum.Contracts

Nethereum Contracts is the core library to interact via RPC with Smart contracts in Ethereum

Neth.TMP

Nethereum unofficial fork that has the following features: * Single nuget package targetting only .NetStandard2.0. * Stable version from upstream's 3.0 (following SemVer). * CancellationToken support (via JsonRpcSharp dependency).

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on ADRaffy.ENSNormalize:

Repository Stars
Nethereum/Nethereum
Ethereum .Net cross platform integration library
Version Downloads Last updated
0.3.0 193 9/14/2024
0.2.0 1,206 9/19/2023
0.1.5 547,740 8/12/2023
0.1.4 330 7/24/2023
0.1.3 211,957 7/8/2023
0.1.2 200 7/4/2023
0.1.1 199 7/3/2023
0.1.0 186 7/3/2023