gpt4 book ai didi

c# - String.StartsWith 在下一个字符是素数符号时不起作用 (char)697

转载 作者:太空狗 更新时间:2023-10-29 20:27:10 27 4
gpt4 key购买 nike

我正在尝试使用其中包含 Prime 符号的字符串,但我在使用 String.StartsWith 方法时遇到了一些问题。为什么下面的代码会抛出异常?

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.");
}

我怀疑问题是因为这个 Prime 符号 (char)697 被视为重音符号,因此正在更改它前面的字母。 (我不认为它应该是——它应该是 the prime symbol,所以不应该改变它前面的数字)。我不确定如何进行测试。我确实尝试了 this answer 中提出的方法,但它返回 false:

IsLetterWithDiacritics(text_1[5]) //  == False
IsLetterWithDiacritics(fullText[5]) // == False
IsLetterWithDiacritics(fullText[6]) // == False

感谢您的帮助。

最佳答案

ʹMODIFIER LETTER PRIME是间距修饰符字母。它不是真正的字符,而是修饰前面字符的特殊用途符号。

From MSDN :

A modifier letter is a free-standing spacing character that, like a combining character, indicates modifications of a preceding letter.


string.StartsWith 返回 false,因为在您的串联字符串中,6 实际上由附加在其后的素数符号修改。

关于c# - String.StartsWith 在下一个字符是素数符号时不起作用 (char)697,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32911688/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com