Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange results from IndexOf on German string

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.

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.

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

Here is the screenshot from the debugger:

enter image description here

like image 342
Antonio Bakula Avatar asked Feb 13 '12 12:02

Antonio Bakula


1 Answers

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

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!

like image 188
3 revs, 2 users 88% Avatar answered Oct 05 '22 01:10

3 revs, 2 users 88%