String.length() vs 国信
String.length() vs national letters
所以我有一个处理文本的程序,我需要获取字符串的长度。
但是如果用我的话来说我有一个国家字母长度方法的输出是不正确的。它为每个国家字母获得额外的 +1,因此它从 "qwerty" returns 6,但如果我使用 "e with a little tail" 而不是常规 'e'.
则为 7
有什么办法可以解决这个问题吗?
此外,对于字母的描述,我感到抱歉,但我认为 Whosebug 将我的国家符号视为语法错误,不允许我 post 提问 :/
它会在 string.Length
页面上告诉您要做什么(强调我的):
The Length property returns the number of Char objects in this
instance, not the number of Unicode characters. The reason is that a
Unicode character might be represented by more than one Char. Use the
System.Globalization.StringInfo class to work with each Unicode
character instead of each Char.
所以我有一个处理文本的程序,我需要获取字符串的长度。 但是如果用我的话来说我有一个国家字母长度方法的输出是不正确的。它为每个国家字母获得额外的 +1,因此它从 "qwerty" returns 6,但如果我使用 "e with a little tail" 而不是常规 'e'.
则为 7有什么办法可以解决这个问题吗?
此外,对于字母的描述,我感到抱歉,但我认为 Whosebug 将我的国家符号视为语法错误,不允许我 post 提问 :/
它会在 string.Length
页面上告诉您要做什么(强调我的):
The Length property returns the number of Char objects in this instance, not the number of Unicode characters. The reason is that a Unicode character might be represented by more than one Char. Use the System.Globalization.StringInfo class to work with each Unicode character instead of each Char.