Make the name uppercase for code point ranges, and cleared the name property of control codes, as per the spec.

This commit is contained in:
GoldenCrystal
2014-11-08 00:15:49 +01:00
parent 11429be6fa
commit f75a21505d
6 changed files with 13 additions and 10 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
TextOptions.TextFormattingMode="Display"
Title="Unicode character inspector"
Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
Height="350" Width="525">
Height="450" Width="525">
<Window.DataContext>
<local:CharacterInspectorViewModel />
</Window.DataContext>
+1 -1
View File
@@ -117,7 +117,7 @@ namespace System.Unicode.Builder
using (var ucdSource = GetUcdSource(null, null, null))
{
data = UnicodeDataManager.BuildDataAsync(ucdSource).Result;
data = UnicodeDataProcessor.BuildDataAsync(ucdSource).Result;
}
using (var stream = new DeflateStream(File.Create("ucd.dat"), CompressionLevel.Optimal, false))
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace System.Unicode.Builder
{
public class UnicodeDataManager
public class UnicodeDataProcessor
{
public const string UnicodeDataFileName = "UnicodeData.txt";
public const string PropListFileName = "PropList.txt";
@@ -55,15 +55,18 @@ namespace System.Unicode.Builder
codePoint = new UnicodeCharacterRange(rangeStartCodePoint, codePoint.LastCodePoint);
name = name.Substring(1, name.Length - 8);
name = name.Substring(1, name.Length - 8).ToUpperInvariant(); // Upper-case the name in order to respect unicode naming scheme. (Spec says all names are uppercase ASCII)
rangeStartCodePoint = -1;
}
else if (name == "<control>") // Ignore the name of the property for these code points, as it should really be empty by the spec.
{
// For control characters, we can derive a character label in of the form <control-NNNN>, which is not the character name.
name = null;
}
else
{
name = name.Substring(1, name.Length - 2);
if (codePoint.IsSingleCodePoint) name = name + "-" + codePoint.ToString();
throw new InvalidDataException("Unexpected code point name tag: " + name + ".");
}
}
else if (rangeStartCodePoint >= 0)
@@ -62,7 +62,7 @@
<Compile Include="UnicodeCharacterDataBuilder.cs" />
<Compile Include="UnicodeDataBuilder.cs" />
<Compile Include="UnicodeDataFileReader.cs" />
<Compile Include="UnicodeDataManager.cs" />
<Compile Include="UnicodeDataProcessor.cs" />
<Compile Include="ZipUcdSource.cs" />
</ItemGroup>
<ItemGroup>
@@ -38,7 +38,7 @@ namespace System.Unicode.Tests
{
var source = new FileUcdSource(UcdDirectoryName);
var data = (await UnicodeDataManager.BuildDataAsync(source)).ToUnicodeData();
var data = (await UnicodeDataProcessor.BuildDataAsync(source)).ToUnicodeData();
Assert.AreEqual((int)'\t', data.Get('\t').CodePoint);
}
@@ -48,7 +48,7 @@ namespace System.Unicode.Tests
{
var source = new FileUcdSource(UcdDirectoryName);
var data = await UnicodeDataManager.BuildDataAsync(source);
var data = await UnicodeDataProcessor.BuildDataAsync(source);
using (var stream = new DeflateStream(File.Create("ucd.dat"), CompressionLevel.Optimal, false))
{
Binary file not shown.