Unicode.Bidi 0.4.0

dotnet add package Unicode.Bidi --version 0.4.0
                    
NuGet\Install-Package Unicode.Bidi -Version 0.4.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="Unicode.Bidi" Version="0.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Unicode.Bidi" Version="0.4.0" />
                    
Directory.Packages.props
<PackageReference Include="Unicode.Bidi" />
                    
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 Unicode.Bidi --version 0.4.0
                    
#r "nuget: Unicode.Bidi, 0.4.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 Unicode.Bidi@0.4.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=Unicode.Bidi&version=0.4.0
                    
Install as a Cake Addin
#tool nuget:?package=Unicode.Bidi&version=0.4.0
                    
Install as a Cake Tool

Unicode.Bidi

.NET port of Rust unicode-bidi. The algorithm tracks crate version 0.3.18; character data tracks Unicode 18.0.0 directly from the Unicode Character Database.

From version 0.4.0, package versions advance independently of the Rust crate. Updating character data can change bidi classification and text ordering; see maintenance for compatibility notes and the update procedure.

The port intentionally keeps source organization close to the Rust crate so individual files can be compared as the implementation grows:

  • src/Unicode.Bidi/char_data mirrors src/char_data.
  • src/Unicode.Bidi/lib.cs mirrors the public BidiInfo construction and reordering APIs from src/lib.rs.
  • src/Unicode.Bidi/level.cs mirrors src/level.rs.
  • src/Unicode.Bidi/format_chars.cs mirrors src/format_chars.rs.
  • src/Unicode.Bidi/explicit.cs, prepare.cs, and implicit.cs mirror the matching Rust modules.

Indexing Policy

.NET strings are UTF-16, so public text ranges and per-code-unit arrays in this port use UTF-16 code-unit indices. The parity harness compares these results against Rust's unicode_bidi::utf16 module.

Usage

Install the package as Unicode.Bidi and import the root namespace:

using Unicode.Bidi;

BidiInfo info = BidiInfo.Create("abc אבג", Level.Ltr());
ParagraphInfo paragraph = info.Paragraphs[0];
string visual = info.ReorderLine(paragraph, paragraph.Range);

BidiClass alefClass = CharData.BidiClass('\u05D0');
Level explicitLevel = Level.CreateExplicit(1);

Rust-compatible factory names such as BidiInfo.New and Level.New are kept for source traceability. .NET-style Create aliases are available on the main entry points.

Local Validation

dotnet restore UnicodeBidiNet.slnx
dotnet build UnicodeBidiNet.slnx --configuration Release --no-restore
dotnet test UnicodeBidiNet.slnx --configuration Release --no-build --nologo

The parity harness compares selected .NET outputs with the original Rust crate:

./tools/fetch-upstream.sh
python3 tools/parity/run_bidi_parity.py --out-dir artifacts/bidi-parity

The parity run requires cargo because the Rust probe is built against unicode-bidi = "=0.3.18". If Rust is not installed globally, use the repo-local bootstrap:

./tools/bootstrap-local-rust.sh
python3 tools/parity/run_bidi_parity.py --out-dir artifacts/bidi-parity

Unicode Conformance

The larger Unicode 18.0.0 conformance files are downloaded on demand into artifacts/:

python3 tools/conformance/fetch_unicode_bidi_tests.py
python3 tools/conformance/run_unicode_bidi_conformance.py \
  --max-cases 1000 \
  --out-dir artifacts/bidi-conformance \
  --fail-on-regression

Use --full for a full local/provisioned run. GitHub Actions runs the full corpus on pull requests, pushes to main, and weekly, and also provides a manual Unicode Conformance workflow.

Performance

The repository contains a BenchmarkDotNet and Criterion comparison harness:

python3 benchmarks/run_comparison.py

Use --quick for a short harness check. The manual Performance benchmarks GitHub Actions workflow runs the same command and uploads both native reports plus the normalized comparison. See docs/performance.md for the measured .NET/Rust results and lookup-strategy analysis.

Packaging

NuGet packages can be produced locally with:

dotnet pack src/Unicode.Bidi/Unicode.Bidi.csproj --configuration Release --output artifacts/packages

Publishing to nuget.org is done through the manual Publish to NuGet GitHub Actions workflow. A successful publication also creates a matching GitHub Release with the package artifacts attached. See docs/publishing.md for the required NuGet Trusted Publishing policy and publish inputs.

See docs/api-compatibility.md and docs/conformance.md for the current parity notes and conformance workflow.

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

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Unicode.Bidi:

Package Downloads
Goo

A retained, declarative UI framework for G#.

PdfBox.Net.SkiaSharp

Complete cross-platform SkiaSharp rendering and glyph layout backend for PdfBox.Net.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0 5,996 11/1/2026
0.3.18 27,961 8/1/2026
0.3.18-preview.1 976 7/7/2026

Algorithm ported from unicode-bidi 0.3.18; Unicode data 18.0.0 generated directly from the Unicode Character Database.