M
Mark
Hi...
One of my coworkers recently discovered that the presence of certain unicode
characters in a string seems to freak out String.IndexOf() and was wondering
why that is. He wrote a little tester program that tested a big chunk of the
range and found some 4000 of them, but I'll just post a little sample with
one here:
char cu = '\u2E01';
string s = cu.ToString();
string s1 = "A " + s;
int idx = s1.IndexOf(s); // returns 0 wrong! (expected 4)
idx = s1.IndexOf(cu); // returns 4
So to sum up, when you hit upon one of these characters IndexOf(char)
returns the right answer but IndexOf(string) - consisting of just the same
char - returns the wrong answer.
Can anyone shed any light on that?
Thanks
Mark
One of my coworkers recently discovered that the presence of certain unicode
characters in a string seems to freak out String.IndexOf() and was wondering
why that is. He wrote a little tester program that tested a big chunk of the
range and found some 4000 of them, but I'll just post a little sample with
one here:
char cu = '\u2E01';
string s = cu.ToString();
string s1 = "A " + s;
int idx = s1.IndexOf(s); // returns 0 wrong! (expected 4)
idx = s1.IndexOf(cu); // returns 4
So to sum up, when you hit upon one of these characters IndexOf(char)
returns the right answer but IndexOf(string) - consisting of just the same
char - returns the wrong answer.
Can anyone shed any light on that?
Thanks
Mark