In VS2012's C# the following code:
string test = "[ " + (char)0xFFFD + " ]";
System.Console.WriteLine("{0}", test.IndexOf(" ") == 1);
results in a
True
printed to console output window. The spaces are separated by 0xFFFD
yet it matches two consecutive spaces. Is that an expected result/feature or a (known) bug?
It's an expected result. FFFD is a "replacement character" in Unicode and is not meaningful in any culture. IndexOf
ignores any non-meaningful characters in its search:
Character sets include ignorable characters, which are characters that are not considered when performing a linguistic or culture-sensitive comparison.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With