icu.net
4.0.1-beta.1
dotnet add package icu.net --version 4.0.1-beta.1
NuGet\Install-Package icu.net -Version 4.0.1-beta.1
<PackageReference Include="icu.net" Version="4.0.1-beta.1" />
<PackageVersion Include="icu.net" Version="4.0.1-beta.1" />
<PackageReference Include="icu.net" />
paket add icu.net --version 4.0.1-beta.1
#r "nuget: icu.net, 4.0.1-beta.1"
#:package icu.net@4.0.1-beta.1
#addin nuget:?package=icu.net&version=4.0.1-beta.1&prerelease
#tool nuget:?package=icu.net&version=4.0.1-beta.1&prerelease
icu.net
Overview
icu-dotnet is the C# wrapper for a subset of ICU.
ICU is a mature, widely used set of C/C++ and Java libraries providing Unicode and Globalization support for software applications. ICU is widely portable and gives applications the same results on all platforms and between C/C++ and Java software.
Usage
This library provides .NET classes and methods for (a subset of) the ICU C API. Please refer to the ICU API documentation. In icu.net you'll find classes that correspond to the C++ classes of ICU4C.
Although not strictly required it is recommended to call Icu.Wrapper.Init() at the start of
the application. This will allow to use icu.net from multiple threads
(c.f. ICU Initialization and Termination).
Similarly, it might be beneficial to call Icu.Wrapper.Cleanup() before exiting.
Sample code:
static class Program
{
public static void Main(string[] args)
{
Icu.Wrapper.Init();
// Will output "NFC form of XA\u0308bc is XÄbc"
Console.WriteLine($"NFC form of XA\\u0308bc is {Icu.Normalizer.Normalize("XA\u0308bc",
Icu.Normalizer.UNormalizationMode.UNORM_NFC)}");
Icu.Wrapper.Cleanup();
}
}
Building
To build the current version of icu-dotnet you'll need .NET 8.0 or .NET 10.0 installed.
icu-dotnet can be built from the command line as well as Visual Studio or JetBrains Rider.
Running Unit Tests
You can build and run the unit tests by running:
dotnet test source/icu.net.sln
or, if wanting to run tests on just one specific .net version (v8.0 in this example):
dotnet test source/icu.net.sln -p:TargetFramework=net8.0
Android
Android support is limited. Only collation APIs are supported for now. Other ICU
functionality (normalization, break iteration, locale handling, and so on) is not yet
available on Android. The Android test project references the full icu.net.tests suite,
but CI and the helper scripts intentionally run only collation tests plus Android-specific
smoke/diagnostic tests.
Prerequisites:
- .NET 10 SDK with the MAUI Android workload:
dotnet workload install maui-android - Android SDK (
ANDROID_HOMEset) with an emulator running or a USB device attached - The
Icu4c.Android.Fw.LibNuGet package (FieldWorks ICU natives + data). The Android test project already references it. icu.net reads the ICU major version from the bundledicudtNl.datasset at runtime, so bumping that native package does not require rebuilding icu.net. Optionally callIcu.Wrapper.ConfineIcuVersions(70)beforeInit()to pin a version, as on other platforms.
Run the filtered Android device test suite (collation + Android-specific tests only):
.\scripts\run-android-tests.ps1
On Linux/macOS (or CI), use bash scripts/ci-android-tests.sh instead. Both scripts apply
the same test filter as CI and print a reminder that only the filtered subset is expected
to pass.
Linux and macOS
It is important for icu.net.dll.config to be bundled with your application when not
running on Windows. If it doesn't copy reliably to the output directory, you might find
adding something like the following to your csproj file will resolve the issue. Note
that the version number in the path must match the version number of icu.net that is
referenced in the project.
<ItemGroup>
<None Update="$(NuGetPackageRoot)\icu.net\2.9.0\contentFiles\any\any\icu.net.dll.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
Docker
icu-dotnet depends on libc dynamic libraries at run time. If running within Docker, you may need to install them, for example:
FROM mcr.microsoft.com/dotnet/aspnet:3.1
# Install system dependencies.
RUN apt-get update \
&& apt-get install -y \
# icu.net dependency: libdl.so
libc6-dev \
&& rm -rf /var/lib/apt/lists/*
...
ICU versions
Collation
With the default normalization mode ICU only guarantees a correct result for input
in FCD form. If yours might not be, set Collator.NormalizationMode to
NormalizationMode.On rather than normalizing each string yourself; ICU's check is
incremental and native, and costs far less.
Linux
icu-dotnet links with any installed version of ICU shared objects. It is recommended to install the version provided by the distribution. For example:
| OS | ICU |
|---|---|
| Ubuntu 22.04 (Jammy) | 70 |
| Ubuntu 24.04 (Noble) | 74 |
| Ubuntu 26.04 (Resolute) | 78 |
| Debian 12 (Bookworm) | 72 |
| Debian 13 (Trixie) | 76 |
If the version provided by the Linux distribution doesn't match your needs, Microsoft's ICU package includes builds for Linux.
Windows
Rather than using the full version of ICU (which can be ~25 MB), a custom minimum build can be used. It can be installed by the Icu4c.Win.Min nuget package. The full version of ICU is also available as Icu4c.Win.Full.Lib and Icu4c.Win.Full.Bin.
Microsoft also makes the full version available as Microsoft.ICU.ICU4C.Runtime.
What's in the minimum build
- Characters
- ErrorCodes
- Locale
- Normalizer
- Rules-based Collator
- Unicode set to pattern conversions
macOS
macOS doesn't come preinstalled with all the normal icu4c libraries. They must be installed separately via a package manager such as Homebrew or MacPorts.
# Homebrew (more common)
brew install icu4c
# MacPorts
sudo port install icu
icu.net automatically searches the standard Homebrew and MacPorts installation directories, so no extra configuration is needed after installing via either package manager.
Troubleshooting
- make sure you added the nuget package
icu.netand have native ICU libraries available. - the binaries of the nuget packages need to be copied to your output directory.
For
icu.netthis happens by the assembly reference that the package adds to your project. The binaries ofIcu4c.Win.Minare only relevant on Windows. They will get copied by theIcu4c.Win.Min.targetsfile included in the nuget package.
On Windows, the package installer should have added an import to the *.csproj file similar
to the following:
<Import Project="..\..\packages\Icu4c.Win.Min.54.1.31\build\Icu4c.Win.Min.targets"
Condition="Exists('..\..\packages\Icu4c.Win.Min.54.1.31\build\Icu4c.Win.Min.targets')" />
Contributing
We love contributions! The library mainly contains the functionality we need for our products. If you miss something that is part of ICU4C but not yet wrapped in icu.net, add it and create a pull request.
If you find a bug - create an issue on GitHub, then preferably fix it and create a pull request!
| Product | Versions 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-android36.0 is compatible. 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 is compatible. 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 | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Extensions.DependencyModel (>= 10.0.9)
- System.ValueTuple (>= 4.6.2)
-
.NETStandard 2.0
- Microsoft.Extensions.DependencyModel (>= 10.0.9)
- System.ValueTuple (>= 4.6.2)
-
net10.0
- Microsoft.Extensions.DependencyModel (>= 10.0.9)
- System.ValueTuple (>= 4.6.2)
-
net10.0-android36.0
- Microsoft.Extensions.DependencyModel (>= 10.0.9)
- System.ValueTuple (>= 4.6.2)
-
net8.0
- Microsoft.Extensions.DependencyModel (>= 10.0.9)
NuGet packages (11)
Showing the top 5 NuGet packages that depend on icu.net:
| Package | Downloads |
|---|---|
|
SIL.WritingSystems
SIL.WritingSystems contains classes for managing and persisting writing systems using the Locale Data Markup Language (LDML) format. This library also contains classes for processing IETF (BCP-47) language tags and accessing the SIL Locale Data Repository (SLDR). |
|
|
SIL.Lib
SIL.Core.dll, SIL.WritingSystems.dll, SIL.Scripture.dll |
|
|
SIL.Windows.Forms.Keyboarding
The SIL.Windows.Forms.Keyboarding library provides cross-platform functionality for keyboard selection and switching in Windows Forms applications. Currently, this library supports system and Keyman keyboards on Windows, and X keyboard extension (XKB) and Intelligent Input Bus (IBus) keyboards on Linux. |
|
|
SIL.WritingSystems.Tests
Unit tests for SIL.WritingSystems |
|
|
ParatextData
Dll for use by third party applications needing to access Paratext's data. Compatible with SIL.Lib 12.0.x (required). Backwards compatible with data from Paratext 8.0 and 9.x. NOTE: This version of ParatextData is built using a AnyCPU configuration, but certain projects will not open correctly when run as 32-bit because of dependencies on native 64-bit libraries. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on icu.net:
| Repository | Stars |
|---|---|
|
lindexi/lindexi_gd
博客用到的代码
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1-beta.1 | 63 | 9/25/2026 |
| 4.0.0 | 508 | 9/23/2026 |
| 4.0.0-beta.38 | 68 | 9/23/2026 |
| 3.0.3-beta.35 | 70 | 9/23/2026 |
| 3.0.3-beta.34 | 204 | 9/23/2026 |
| 3.0.3-beta.33 | 75 | 9/23/2026 |
| 3.0.3-beta.32 | 67 | 9/22/2026 |
| 3.0.3-beta.31 | 60 | 9/22/2026 |
| 3.0.3-beta.27 | 63 | 9/22/2026 |
| 3.0.3-beta.22 | 69 | 9/18/2026 |
| 3.0.3-beta.19 | 69 | 9/18/2026 |
| 3.0.3-beta.7 | 115 | 6/11/2026 |
| 3.0.3-beta.6 | 103 | 6/11/2026 |
| 3.0.3-beta.5 | 85 | 6/10/2026 |
| 3.0.3-beta.4 | 90 | 6/10/2026 |
| 3.0.3-beta.3 | 90 | 6/8/2026 |
| 3.0.3-beta.2 | 84 | 6/8/2026 |
| 3.0.3-beta.1 | 94 | 6/3/2026 |
| 3.0.2 | 72,004 | 6/2/2026 |
| 3.0.1 | 144,273 | 2/21/2025 |
Changes since version 4.0.0
Fixed:
- Fixed `TypeInitializationException` (`UriFormatException: Invalid URI: The hostname could not be
parsed`) on first use when the path of `icu.net.dll` is longer than `MAX_PATH` on Windows. .NET
returns such paths with a `\\?\` prefix, which `new Uri(...)` could not parse.
See full changelog at https://github.com/sillsdev/icu-dotnet/blob/master/CHANGELOG.md.