Use ASCII as display text for "TAG" characters at U+E0000.

This commit is contained in:
GoldenCrystal
2017-06-25 20:09:54 +02:00
parent 642b675b3d
commit d65f7f0a77
7 changed files with 36 additions and 21 deletions
+2 -2
View File
@@ -15,5 +15,5 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]
+1 -1
View File
@@ -4,6 +4,6 @@
<Authors>Fabien Barbier</Authors>
<Copyright>Copyright © Fabien Barbier 2014-2017</Copyright>
<NeutralLanguage>en</NeutralLanguage>
<Version>2.1.0</Version>
<Version>2.2.0</Version>
</PropertyGroup>
</Project>
+2 -1
View File
@@ -11,7 +11,8 @@ The other, is a small WPF application allowing to inspect the Unicode code point
Version of Unicode supported
----------------------------
Unicode 9.0.0
Unicode 10.0.0
Emoji 5.0
Using the Unicode Character Inspector application
-------------------------------------------------
@@ -88,7 +88,7 @@ namespace UnicodeCharacterInspector
if (displayText != oldValue) NotifyPropertyChanged(nameof(DisplayText));
}
public string DisplayText { get { return displayText; } }
public string DisplayText => displayText;
public int? CodePoint => character != null ? codePoint : null as int?;
@@ -14,16 +14,23 @@
<Link>System.Unicode.snk</Link>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="UnihanProperty.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>UnihanProperty.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\UnicodeInformation\UnicodeInformation.csproj" />
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<ItemGroup>
<Compile Update="UnihanProperty.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>UnihanProperty.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="UnihanProperty.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>UnihanProperty.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>
+1 -1
View File
@@ -14,7 +14,7 @@ namespace System.Unicode
private readonly int codePoint;
/// <summary>The name of the code point.</summary>
private readonly string name;
private readonly int unicodeCharacterDataIndex;
internal readonly int unicodeCharacterDataIndex;
private readonly int unihanCharacterDataIndex;
private readonly string block;
+16 -9
View File
@@ -2,6 +2,7 @@
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
namespace System.Unicode
@@ -420,25 +421,31 @@ namespace System.Unicode
/// <summary>Gets a display text for the specified code point.</summary>
/// <param name="charInfo">The information for the code point.</param>
/// <returns>A display text for the code point, which may be the representation of the code point itself.</returns>
public static string GetDisplayText(UnicodeCharInfo charInfo)
{
if (charInfo.CodePoint <= 0x0020) return ((char)(0x2400 + charInfo.CodePoint)).ToString();
else if (charInfo.Category == UnicodeCategory.NonSpacingMark) return "\u25CC" + char.ConvertFromUtf32(charInfo.CodePoint);
else if (charInfo.CodePoint >= 0xD800 && charInfo.CodePoint <= 0xDFFF) return "\xFFFD";
else return char.ConvertFromUtf32(charInfo.CodePoint);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static string GetDisplayText(this UnicodeCharInfo charInfo)
=> GetDisplayText(charInfo.CodePoint, charInfo.unicodeCharacterDataIndex);
/// <summary>Gets a display text for the specified code point.</summary>
/// <param name="codePoint">The Unicode code point, for which a display text should be returned.</param>
/// <returns>A display text for the code point, which may be the representation of the code point itself.</returns>
public static string GetDisplayText(int codePoint)
{
if (codePoint <= 0x0020) return ((char)(0x2400 + codePoint)).ToString();
else if (GetCategory(codePoint) == UnicodeCategory.NonSpacingMark) return "\u25CC" + char.ConvertFromUtf32(codePoint);
if (codePoint <= 0x0020) return ((char)(0x2400 + codePoint)).ToString(); // Provide a display text for control characters, including space.
else if (GetCategory(codePoint) == UnicodeCategory.NonSpacingMark) return "\u25CC" + char.ConvertFromUtf32(codePoint);
else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) return "\xFFFD";
else if (codePoint >= 0xE0020 && codePoint < 0xE007F) return char.ConvertFromUtf32(codePoint - 0xE0000); // Handle "TAG" ASCII subset by remapping it to regular ASCII
else return char.ConvertFromUtf32(codePoint);
}
private static string GetDisplayText(int codePoint, int unicodeCharacterDataIndex)
{
if (codePoint <= 0x0020) return ((char)(0x2400 + codePoint)).ToString(); // Provide a display text for control characters, including space.
else if (GetUnicodeCharacterData(unicodeCharacterDataIndex).Category == UnicodeCategory.NonSpacingMark) return "\u25CC" + char.ConvertFromUtf32(codePoint);
else if (codePoint >= 0xD800 && codePoint <= 0xDFFF) return "\xFFFD";
else if (codePoint >= 0xE0020 && codePoint < 0xE007F) return char.ConvertFromUtf32(codePoint - 0xE0000); // Handle "TAG" ASCII subset by remapping it to regular ASCII
else return char.ConvertFromUtf32(codePoint);
}
/// <summary>Gets the name of the specified code point.</summary>
/// <remarks>
/// The name referred to is the unicode Name property.