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 中。