Migrate database and project to Unicode 9.0.0.
This commit is contained in:
@@ -15,5 +15,5 @@ using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.1.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.1.0")]
|
||||
[assembly: AssemblyVersion("2.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("2.0.0.0")]
|
||||
|
||||
@@ -9,12 +9,20 @@ This projects has two parts.
|
||||
One is a library, providing access to some of the data contained in the Unicode Character Database by the means of a portable .NET assembly.
|
||||
The other, is a small WPF application allowing to inspect the Unicode code points composing a specified text.
|
||||
|
||||
Version of Unicode supported
|
||||
----------------------------
|
||||
Unicode 9.0.0
|
||||
|
||||
Using the Unicode Character Inspector application
|
||||
-------------------------------------------------
|
||||
Simply launch the application, then type or paste some text in the text box on the top of the window.
|
||||
The code points will be displayed in the list on the left side. Select one of them to display the associated information in the bottom-right pane.
|
||||

|
||||
|
||||
Breaking changes from versions 1.x to 2.x
|
||||
-----------------------------------------
|
||||
UnicodeRadicalStrokeCount.StrokeCount is now of type System.SByte instead of type System.Byte.
|
||||
|
||||
Compiling and using the project
|
||||
-------------------------------
|
||||
### Using the UnicodeInformation library
|
||||
@@ -56,7 +64,7 @@ This example shows a few usages of the library. It gets information on a specifi
|
||||
### Details
|
||||
In its current state, the project is written in C# 6, compilable by [Roslyn](http://roslyn.codeplex.com/), and targets the .NET 4.5 framework.
|
||||
The core of the project, UnicodeInformation.dll, is a portable class library usable for either regular .NET or Windows 8 applications.
|
||||
This library includes a subset of the official [Unicode Character Database](http://www.unicode.org/Public/UCD/latest/) (Version 8.0 at the time of writing) stored in a custom file format.
|
||||
This library includes a subset of the official [Unicode Character Database](http://www.unicode.org/Public/UCD/latest/) stored in a custom file format.
|
||||
|
||||
### Included Properties
|
||||
#### From UCD
|
||||
|
||||
@@ -542,7 +542,7 @@ namespace System.Unicode.Builder
|
||||
throw new InvalidDataException("Failed to decode value for kRSUnicode / Unicode_Radical_Stroke.");
|
||||
|
||||
SeparatorFound:;
|
||||
entry.UnicodeRadicalStrokeCounts.Add(new UnicodeRadicalStrokeCount(byte.Parse(value.Substring(0, index), NumberStyles.None), byte.Parse(value.Substring(index + (isSimplified ? 2 : 1)), NumberStyles.None), isSimplified));
|
||||
entry.UnicodeRadicalStrokeCounts.Add(new UnicodeRadicalStrokeCount(byte.Parse(value.Substring(0, index), NumberStyles.None), sbyte.Parse(value.Substring(index + (isSimplified ? 2 : 1)), NumberStyles.AllowLeadingSign), isSimplified));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace System.Unicode.Builder
|
||||
foreach (var radicalStrokeCount in unicodeRadicalStrokeCounts)
|
||||
{
|
||||
writer.Write(radicalStrokeCount.Radical);
|
||||
writer.Write((byte)(radicalStrokeCount.StrokeCount | (radicalStrokeCount.IsSimplified ? 0x80 : 0)));
|
||||
writer.Write(radicalStrokeCount.RawStrokeCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,12 @@ namespace UnicodeInformation.Tests
|
||||
[TestClass]
|
||||
public class UnicodeInfoTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void UnicodeVersionTest()
|
||||
{
|
||||
Assert.AreEqual(new Version(9, 0, 0), UnicodeInfo.UnicodeVersion);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CodePointEnumeratorTest()
|
||||
{
|
||||
@@ -179,6 +185,7 @@ namespace UnicodeInformation.Tests
|
||||
AssertChar(0x00E9, UnicodeCategory.LowercaseLetter, "LATIN SMALL LETTER E WITH ACUTE", "Latin-1 Supplement");
|
||||
AssertChar(0xD4DB, UnicodeCategory.OtherLetter, "HANGUL SYLLABLE PWILH", "Hangul Syllables");
|
||||
AssertChar(0x1F574, UnicodeCategory.OtherSymbol, "MAN IN BUSINESS SUIT LEVITATING", "Miscellaneous Symbols and Pictographs");
|
||||
AssertChar(0x17000, UnicodeCategory.OtherLetter, "TANGUT IDEOGRAPH-17000", "Tangut");
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
|
||||
<TargetFrameworkProfile>Profile7</TargetFrameworkProfile>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<_WindowsKitBinPath>C:\Program Files (x86)\Windows Kits\8.1\bin\x86</_WindowsKitBinPath>
|
||||
@@ -32,7 +33,6 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
|
||||
<DocumentationFile>bin\Debug\UnicodeInformation.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
@@ -41,7 +41,6 @@
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>bin\Release\UnicodeInformation.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SignAssembly>true</SignAssembly>
|
||||
@@ -58,6 +57,7 @@
|
||||
<EmbeddedResource Include="ucd.dat">
|
||||
<LogicalName>ucd.dat</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<None Include="UnicodeInformation.nuspec" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\AssemblyInfo.Common.cs">
|
||||
|
||||
@@ -11,7 +11,11 @@
|
||||
<iconUrl>https://raw.githubusercontent.com/GoldenCrystal/NetUnicodeInfo/master/UnicodeCharacterInspector/UnicodeCharacterInspector.ico</iconUrl>
|
||||
<requireLicenseAcceptance>false</requireLicenseAcceptance>
|
||||
<description>$description$</description>
|
||||
<releaseNotes></releaseNotes>
|
||||
<releaseNotes>
|
||||
Version 2.0
|
||||
-------------
|
||||
Following migration to Unicode 9.0.0, UnicodeRadicalStrokeCount.StrokeCount is now of type System.SByte instead of type System.Byte.
|
||||
</releaseNotes>
|
||||
<copyright>Copyright 2014</copyright>
|
||||
<tags>Unicode Unihan Data .NET C# String Text Char Character CodePoint Code Point</tags>
|
||||
</metadata>
|
||||
|
||||
@@ -12,31 +12,45 @@ namespace System.Unicode
|
||||
{
|
||||
internal static readonly UnicodeRadicalStrokeCount[] EmptyArray = new UnicodeRadicalStrokeCount[0];
|
||||
|
||||
/// <summary>The radical index.</summary>
|
||||
private readonly byte radical;
|
||||
/// <summary>The stroke count as a 7bit signed value, together with the <see cref="IsSimplified"/> flag as a 1bit value.</summary>
|
||||
private readonly byte strokeCount;
|
||||
|
||||
/// <summary>Initializes a new instance of the class <see cref="UnicodeRadicalStrokeCount"/> from raw data.</summary>
|
||||
/// <param name="rawRadical">The raw value to use for <see cref="radical"/>.</param>
|
||||
/// <param name="rawStrokeCount">The raw value to use for <see cref="strokeCount"/>.</param>
|
||||
internal UnicodeRadicalStrokeCount(byte rawRadical, byte rawStrokeCount)
|
||||
{
|
||||
radical = rawRadical;
|
||||
strokeCount = rawStrokeCount;
|
||||
}
|
||||
|
||||
internal UnicodeRadicalStrokeCount(byte radical, byte strokeCount, bool isSimplified)
|
||||
/// <summary>Initializes a new instance of the class <see cref="UnicodeRadicalStrokeCount"/>.</summary>
|
||||
/// <remarks><paramref name="strokeCount"/> must be between -64 and 63 included.</remarks>
|
||||
/// <param name="radical">The index of the Kangxi radical of the character.</param>
|
||||
/// <param name="strokeCount">The number of additional strokes required to form the character from the radical.</param>
|
||||
/// <param name="isSimplified">Indicates whether the character is simplified.</param>
|
||||
/// <exception cref="ArgumentOutOfRangeException"><paramref name="strokeCount"/> is outside of the allowed range.</exception>
|
||||
internal UnicodeRadicalStrokeCount(byte radical, sbyte strokeCount, bool isSimplified)
|
||||
{
|
||||
if (strokeCount < -64 || strokeCount > 63) throw new ArgumentOutOfRangeException(nameof(strokeCount));
|
||||
|
||||
this.radical = radical;
|
||||
if (isSimplified) strokeCount |= 0x80;
|
||||
this.strokeCount = strokeCount;
|
||||
// Pack strokeCount together with isSimplified in a single byte.
|
||||
this.strokeCount = unchecked((byte)(strokeCount & 0x7F | (isSimplified ? 0x80 : 0x00)));
|
||||
}
|
||||
|
||||
/// <summary>Gets the index of the Kangxi radical of the character.</summary>
|
||||
/// <remarks>The Kangxi radicals are numbered from 1 to 214 inclusive.</remarks>
|
||||
/// <value>The index of the Kangxi radical.</value>
|
||||
public byte Radical { get { return radical; } }
|
||||
/// <summary>Gets the value of <see cref="StrokeCount"/> packed with <see cref="IsSimplified"/>.</summary>
|
||||
/// <value>The raw value of <see cref="strokeCount"/>.</value>
|
||||
internal byte RawStrokeCount { get { return strokeCount; } }
|
||||
/// <summary>Gets the additional stroke count.</summary>
|
||||
/// <value>
|
||||
/// The stroke count.
|
||||
/// </value>
|
||||
public byte StrokeCount { get { return (byte)(strokeCount & 0x7F); } }
|
||||
/// <value>The additional stroke count.</value>
|
||||
public sbyte StrokeCount { get { return unchecked((sbyte)(strokeCount & 0x7F | (strokeCount & 0x40) << 1)); } } // To unpack the stroke count, we simply need to copy bit 6 to bit 7.
|
||||
/// <summary>Gets a value indicating whether the information is based on the simplified form of the radical.</summary>
|
||||
/// <value><see langword="true" /> if the information is based on the simplified form of the radical; otherwise, <see langword="false" />.</value>
|
||||
public bool IsSimplified { get { return (strokeCount & 0x80) != 0; } }
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user