I am trying to use a string with the Prime symbol in it, but I am having some issues with the String.StartsWith method. Why is the following code throwing the exception?
string text_1 = @"123456";
string text_2 = @"ʹABCDEF";
string fullText = text_1 + text_2;
if (!fullText.StartsWith(text_1))
{
throw new Exception("Unexplained bad error.");
}
I suspect that the issue is because this Prime symbol (char)697 is being treated as an accent and so is changing the letter before it. (I don't think it should be - it should be the the prime symbol and so should not be changing the numerical numbers in front of it). I am not exactly sure how to go about testing this. I did try the method proposed in this answer but it returned false:
IsLetterWithDiacritics(text_1[5]) // == False
IsLetterWithDiacritics(fullText[5]) // == False
IsLetterWithDiacritics(fullText[6]) // == False
Thanks for any help.
StringComparison
type and telling it to use theInvariantCulture
or theOrdinal
? – MatersefullText.StartsWith(text_1, StringComparison.Ordinal)
will work. – Nankeen