Can someone explain this behavior?
" ".EndsWith(((char)9917).ToString()) // returns true
StartsWith works same.
Can someone explain this behavior?
" ".EndsWith(((char)9917).ToString()) // returns true
StartsWith works same.
.NET Framework 4 on Windows 7 includes support for Unicode 5.1:
The culture-sensitive sorting and casing rules used in string comparison depend on the version of the .NET Framework. In the .NET Framework 4, sorting, casing, normalization, and Unicode character information is synchronized with Windows 7 and conforms to the Unicode 5.1 standard.
The character you're using is a Unicode 5.2 character, so it's likely to not behave correctly in any function other than those that compare characters by number only.
You should see different behaviour (but I cannot test it right now) on Windows 8, and .NET 4.5: according to the documentation, in that case, Unicode 6.0 is supported. According to Thomas Levesque in the comments, contrary to the documentation, this has not been changed in later versions.
As mentioned in the comments, the endswith
Method uses the current Culture, if no StringComparison Type is provided.
You can get it working, by using an ordinal comparission:
" ".EndsWith(((char)9917).ToString(), StringComparison.Ordinal); //false
(Ordinal will ultimately compare the bytes
of the chars to determine equality)