BlueBird.Pinyins
1.3.0
dotnet add package BlueBird.Pinyins --version 1.3.0
NuGet\Install-Package BlueBird.Pinyins -Version 1.3.0
<PackageReference Include="BlueBird.Pinyins" Version="1.3.0" />
<PackageVersion Include="BlueBird.Pinyins" Version="1.3.0" />
<PackageReference Include="BlueBird.Pinyins" />
paket add BlueBird.Pinyins --version 1.3.0
#r "nuget: BlueBird.Pinyins, 1.3.0"
#:package BlueBird.Pinyins@1.3.0
#addin nuget:?package=BlueBird.Pinyins&version=1.3.0
#tool nuget:?package=BlueBird.Pinyins&version=1.3.0
BlueBird.Pinyins
A lightweight, zero-dependency .NET library for converting Chinese characters to Pinyin, extracting initials, and finding characters by Pinyin.
Installation
dotnet add package BlueBird.Pinyins
Quick Start
using System.Text;
using BlueBird.Pinyins;
Pinyin.GetPinyin("中国"); // "zhongguo"
Pinyin.GetPinyin("中国", " "); // "zhong guo"
Pinyin.GetInitials("你好"); // "nh"
Pinyin.GetInitials("你好", "-"); // "n-h"
Pinyin.GetPinyin(new Rune('中')); // "zhong"
Pinyin.TryGetPinyin(new Rune('中'), out string? pinyin); // true
Pinyin.GetCharacters("zhong"); // "中种重众钟..."
API
| Method | Description |
|---|---|
GetPinyin(string?, string?) |
Converts text to Pinyin. An optional separator is inserted between the result for each input character. |
GetInitials(string?, string?) |
Extracts Pinyin initials. An optional separator is inserted between the result for each input character. |
GetPinyin(Rune) |
Returns the Pinyin for one Unicode character, or the original character when it is not found. |
TryGetPinyin(Rune, out string?) |
Attempts to find the Pinyin for one Unicode character. |
GetCharacters(string?) |
Returns the characters matching a complete, tone-free Pinyin syllable. |
The string APIs return null when their input is null. GetCharacters trims surrounding whitespace, ignores case, and returns an empty string when no match is found.
Limitations
- Each character maps to one default tone-free Pinyin reading. Context-dependent pronunciations and tones are not supported.
- The library uses
vforü, as inlv,nv,lve, andnve. - When converting text, characters not included in the Pinyin data are returned unchanged.
Upgrading from 1.2
Version 1.3 renames GetChineseText to GetCharacters and replaces GetPinyin(char) with the Unicode-safe GetPinyin(Rune) API.
Implementation
- No runtime dependencies; all Pinyin data is embedded in the assembly.
- Text is processed with
Runeto preserve Unicode surrogate pairs.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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-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. |
-
net10.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Breaking changes: GetChineseText is renamed to GetCharacters, and GetPinyin(char) is replaced by GetPinyin(Rune). Also adds TryGetPinyin, Unicode-safe text handling, faster character lookup, broader simplified and traditional Chinese character coverage, and improved default Pinyin mappings.