ADRaffy.ENSNormalize 0.3.0

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

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

ENSNormalize.cs

0-dependency ENSIP-15 in C#

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"

Additional NormDetails (Experimental)

// works like Normalize(), throws on invalid names
// string -> NormDetails
NormDetails details = ENSNormalize.ENSIP15.NormalizeDetails("💩ì.a");

string Name; // normalized name
bool PossiblyConfusing; // if name should be carefully reviewed
HashSet<Group> Groups; // unique groups in name
HashSet<EmojiSequence> Emojis; // unique emoji in name
string GroupDescription = "Emoji+Latin"; // group summary for name
bool HasZWJEmoji; // if any emoji contain 200D

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: NormException { Kind: "underscore allowed only at start" }
//   }
// ]

Normalization Properties

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

Error Handling

All errors are safe to print. NormException { Kind: string, Reason: string? } is the base exception. Functions that accept names as input wrap their exceptions in InvalidLabelException { Label: string, Error: NormException } for additional context.

  • "disallowed character"DisallowedCharacterException { Codepoint }
  • "illegal mixture"IllegalMixtureException { Codepoint, Group, OtherGroup? }
  • "whole-script confusable"ConfusableException { Group, OtherGroup }
  • "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"

Utilities

Normalize name fragments for substring search:

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

Construct safe strings:

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

Determine if a character shouldn't be printed directly:

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

Determine if a character is a combining mark:

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

Unicode Normalization Forms NF

using ADRaffy.ENSNormalize;

// string -> string
ENSNormalize.NF.NFC("\x65\u0300"); // "\xE8"
ENSNormalize.NF.NFD("\xE8");       // "\x65\u0300"

// IEnumerable<int> -> List<int>
ENSNormalize.NF.NFC(new int[]{ 0x65, 0x300 }); // [0xE8]
ENSNormalize.NF.NFD(new int[]{ 0xE8 });        // [0x65, 0x300]
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 net35 is compatible.  net40 was computed.  net403 was computed.  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 3.5

    • 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 250 9/14/2024
0.2.0 1,219 9/19/2023
0.1.5 615,401 8/12/2023
0.1.4 342 7/24/2023
0.1.3 214,493 7/8/2023
0.1.2 213 7/4/2023
0.1.1 207 7/3/2023
0.1.0 195 7/3/2023