I am trying to use a string with the main character in it, but I'm having some problems with the String.StartsWith method. Why does the following code throw an 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 the problem is that this main character (char) 697 is treated as an accent and therefore changes the letter before it. (I don’t think it should be - it should be the main character , and therefore, do not change the numbers in front of it). I'm not quite sure how to do this. I tried the method suggested in this answer , but it returned false:
IsLetterWithDiacritics(text_1[5]) // == False IsLetterWithDiacritics(fullText[5]) // == False IsLetterWithDiacritics(fullText[6]) // == False
Thanks for any help.
string c # startswith escaping diacritics
Ben
source share