I think I'll have a try.
From what I get, is that U+2D2D was added in Unicode v6.1 (source / source).
The .NET framework, or the native calls rather, support a lower version:
The culture-sensitive sorting and casing rules used in string
comparison depend on the version of the .NET Framework. In the .NET
Framework 4.5 running on the Windows 8 operating system, sorting,
casing, normalization, and Unicode character information conforms to
the Unicode 6.0 standard. On other operating systems, it conforms to
the Unicode 5.0 standard. (source)
Thus it is required to mark it as an ignorable character, which behaves just as if the character wasn't even there.
Character sets include ignorable characters, which are characters that
are not considered when performing a linguistic or culture-sensitive
comparison. (source)
Example:
var culture = new CultureInfo("en-US");
int result = culture.CompareInfo.Compare("", "\u2D2D", CompareOptions.None);
Assert.AreEqual(0, result);
string.StartsWith
uses a similar implementation, but uses CompareInfo.IsPrefix(string, string, CompareOptions)
instead.
false
for me:Enumerable.Range(0, 10000).Any(x => !((char)x).ToString().StartsWith("\u2D2D"))
– BlintzU+2D2D
is supposed to have a length of 1. – Conventicle2D2A
and the like. – SplashyString.StartsWith
here: referencesource.microsoft.com/#mscorlib/system/… – DisembodyCompareInfo.cs
: referencesource.microsoft.com/#mscorlib/system/globalization/…, and its all native from there on. I don't understand the win32 API sufficiently to be able to debug what is going on with the windows native code. – DisembodyUnicodeCategory.OtherNotAssigned
content matches this strange case. Can be checked withCultureInfo.CurrentCulture.CompareInfo.Compare("", "" + (char)c, CompareOptions.None) == 0
, of which CurrentCulture = "en-US" – Sweepstake