从的IndexOf奇怪的结果对德国字符串德国、字符串、奇怪、结果

2023-09-04 07:45:27 作者:°心若相依

我有字符串Ärger,-Ökonom-I-Übermut-ẞ-SS,当我运行的IndexOf( - )我得到23结果。如果我用替换在相同的字符串没有被替换。

I have string "Ärger,-Ökonom-i-Übermut-ẞ-ß" and when I run IndexOf("--") I get a result of 23. If I use Replace on same string nothing gets replaced.

我不明白发生了什么,所以有人可以阐明这个问题一些启示?应用文化坐落在克罗地亚,这不是德国人,和框架的版本是3.5。

I don't understand what is happening, so can someone please shed some light on this issue? Application Culture is set on Croatian, it's not German, and framework version is 3.5.

改变文化,德国(DE-DE)不会改变这种奇怪的行为。

Changing culture to German (de-DE) doesn't change this strange behavior.

下面是从调试器的截图:

Here is the screenshot from the debugger:

推荐答案

由于李斯特先生不希望他当之无愧upvotes,我会贴上他的意见在这里,接受的答案。

Since Mr Lister doesn't want his well deserved upvotes, I will paste his comment here, and accept answer.

我怕U + 1E9E根据.NET 3.5不确定的,因为   这个人物并没有在统一code 4.0存在(或任何版本   统一code .NET 3.5用途)。这是一个相当新的加法(大写版本   德国党卫军的)。因此,的IndexOf函数忽略它。如果您有任何   在文本控件,你可以改变字符SS或SS,   无论是比较合适的。当然更好的解决办法是将   升级.NET到V4.0!

I'm afraid that U+1E9E is undefined according to .NET 3.5, because this character didn't exist in Unicode 4.0 (or whatever version of Unicode .NET 3.5 uses). It's a fairly new addition (uppercase version of German ß). So the IndexOf function ignores it. If you have any control over the text, you could change the character to ß or SS, whatever is more appropriate. Of course the better solution is to upgrade .NET to v4.0!