Rebuilt the data file, and fixed the handling of name aliases.

This commit is contained in:
GoldenCrystal
2014-11-21 17:04:55 +01:00
parent b148e69ca0
commit 2324d2c272
5 changed files with 10 additions and 13 deletions
@@ -104,7 +104,7 @@ namespace UnicodeCharacterInspector
public UnicodeNameAliasCollection NameAliases
{
get { return characterInfo.NameAliases; }
get { return character != null ? characterInfo.NameAliases : new UnicodeNameAliasCollection(); }
}
public string OldName
+6 -1
View File
@@ -53,6 +53,9 @@
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Margin" Value="6" />
</Style>
<Style TargetType="{x:Type ItemsControl}" BasedOn="{StaticResource ResourceKey={x:Type ItemsControl}}">
<Setter Property="Margin" Value="6" />
</Style>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width ="Auto" />
@@ -95,7 +98,9 @@
<ItemsControl Grid.Row="3" Grid.Column="1" Visibility="{Binding SelectedCharacterInfo.NameAliases.Count, Converter={StaticResource ZeroToVisibilityConverter}}" ItemsSource="{Binding SelectedCharacterInfo.NameAliases}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock TextWrapping="WrapWithOverflow" Text="{Binding}" />
<TextBlock TextWrapping="WrapWithOverflow">
<Run Text="{Binding Name, Mode=OneTime}" /> (<Run Text="{Binding Kind, Mode=OneTime}" />)
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -57,11 +57,8 @@ namespace System.Unicode.Builder
/// <param name="nameAlias">The name alias value to write.</param>
public static void WriteNameAliasToFile(this BinaryWriter writer, UnicodeNameAlias nameAlias)
{
// This method will stuff two extra bits together with the byte count, provided that this one doesn't exceed 64.
var bytes = Encoding.UTF8.GetBytes(nameAlias.Name);
if (bytes.Length > 64) throw new InvalidOperationException("Did not expect UTF-8 encoded name aliases to be longer than 64 bytes.");
writer.WritePackedLength((byte)(nameAlias.Kind - 1), nameAlias.Name.Length);
writer.Write(bytes);
writer.Write(nameAlias.Name);
writer.Write((byte)nameAlias.Kind);
}
/// <summary>Writes a character name, packing two information bits along with the length.</summary>
+1 -6
View File
@@ -107,12 +107,7 @@ namespace System.Unicode
for (int i = 0; i < nameAliases.Length; ++i)
{
length = reader.ReadByte();
UnicodeNameAliasKind aliasKind = (UnicodeNameAliasKind)((length >> 6) + 1);
length = (length & 0x3F) + 1;
if (reader.Read(nameBuffer, 0, length) != length) throw new EndOfStreamException();
nameAliases[i] = new UnicodeNameAlias(Encoding.UTF8.GetString(nameBuffer, 0, length), aliasKind);
nameAliases[i] = new UnicodeNameAlias(reader.ReadString(), (UnicodeNameAliasKind)(reader.ReadByte()));
}
}
}
Binary file not shown.