NetUnicodeInfo
New stable release of the Unicode Character Inspector, and NuGet package for the library
該專案由一個庫組成,該庫提供對 Unicode 字元資料庫中包含的某些資料的存取。
統一碼 13.0 表情符號 13.0
UnicodeRadicalStrokeCount.StrokeCount 現在是 System.SByte 類型,而不是 System.Byte 類型。
在 NuGet 上取得該套件的最新版本:https://www.nuget.org/packages/UnicodeInformation/。將庫安裝到專案後,您將在 System.Unicode 命名空間中找到所需的所有內容。
該庫提供的所有內容都將位於名稱空間System.Unicode
下。 XML 文件應該足夠完整,以便您可以導覽 API 而不會迷失方向。
在目前狀態下,該專案是用 C# 7.3 編寫的,可由 Roslyn 編譯,並且面向 .NET Standard 2.0 和 .NET Standard 1.1。 UnicodeInformation 庫包含以自訂檔案格式儲存的官方 Unicode 字元資料庫的(大型)子集。
下面的程式將顯示一些字元的資訊:
using System ;
using System . Text ;
using System . Unicode ;
namespace Example
{
internal static class Program
{
private static void Main ( )
{
Console . OutputEncoding = Encoding . Unicode ;
PrintCodePointInfo ( 'A' ) ;
PrintCodePointInfo ( '∞' ) ;
PrintCodePointInfo ( 0x1F600 ) ;
}
private static void PrintCodePointInfo ( int codePoint )
{
var charInfo = UnicodeInfo . GetCharInfo ( codePoint ) ;
Console . WriteLine ( UnicodeInfo . GetDisplayText ( charInfo ) ) ;
Console . WriteLine ( "U+" + codePoint . ToString ( "X4" ) ) ;
Console . WriteLine ( charInfo . Name ?? charInfo . OldName ) ;
Console . WriteLine ( charInfo . Category ) ;
}
}
}
說明:
UnicodeInfo.GetCharInfo(int)
傳回一個結構UnicodeCharInfo
,它提供與指定代碼點關聯的各種資訊位元的存取。UnicodeInfo.GetDisplayText(UnicodeCharInfo)
是一種幫助程式方法,用於計算指定程式碼點的顯示文字。由於某些代碼點未設計為以獨立方式顯示,因此這將嘗試使指定的字元更易於顯示。用於提供顯示文字的演算法非常簡單,並且只會影響非常具體的程式碼點。 (例如控製字元)對於大多數程式碼點,這將簡單地傳回直接字串表示形式。UnicodeCharInfo.Name
傳回 Unicode 標準指定的代碼點的名稱。請注意,根據設計,某些字元在標準中不會分配任何名稱。 (例如控製字元)但是,這些字元可能會指派備用名稱,您可以將其用作備用名稱。 (例如UnicodeCharInfo.OldName
)UnicodeCharInfo.OldName
傳回 Unicode 1.0 中定義的字元名稱(如果適用且與目前名稱不同)。UnicodeCharInfo.Category
傳回指派給指定代碼點的類別。注意:UCD 屬性 ISO_Comment 永遠不會被包含,因為該屬性在所有新的 Unicode 版本中都是空的。
專案 UnicodeInformation.Builder 負責產生名為 ucd.dat 的檔案。該檔案包含由 .NET 的 deflate 演算法壓縮的 Unicode 數據,並且應在編譯時包含在 UnicodeInformation.dll 中。