Herfried,
| U+FEFF is "deprecated" and U+2060 should be used instead because U+FEFF is
a
| typical UTF-BOM too.
I was going to say it looked like a BOM, odd it is (was) also a character.
| > FWIW: I tried StringComparison.InvariantCulture above & it also returns
| > true.
|
| Sure, I know! I have read a lot of code but I have rarely seen anybody
| specifying this option, even if it should have been specified.
I try to use StringComparison.InvariantCulture & StringComparison.Ordinal
where appropriate:
http://blogs.msdn.com/bclteam/archive/2005/06/01/424012.aspx
http://msdn.microsoft.com/netframew...ibrary/en-us/dndotnet/html/StringsinNET20.asp
Although sometimes I forget to use them initially, then remember on
subsequent code reviews... FWIW: I should thank you! Looking for where I
used the option I noticed a handful of places where I should have used
StringComparison.Ordinal instead of StringComparison.InvariantCulture! I'll
need to change them sometime today...
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
| > What is character ChrW(&HFEFF) anyway?
|
| U+FEFF "ZERO WIDTH NON-BREAKING SPACE"
| U+2060 "WORD JOINER"
|
| U+FEFF is "deprecated" and U+2060 should be used instead because U+FEFF is
a
| typical UTF-BOM too. However, the behavior is the same for the U+2060
| character. The problem I am seeing is that the behavior changed from .NET
| 1.* to .NET 2.0.
|
| > You could always use:
| >
| > MsgBox("Foo".StartsWith(ChrW(&HFEFF) & "Foo",
| > StringComparison.OrdinalIgnoreCase))
| >
| > FWIW: I tried StringComparison.InvariantCulture above & it also returns
| > true.
|
| Sure, I know! I have read a lot of code but I have rarely seen anybody
| specifying this option, even if it should have been specified.
|
| > In VB6 did you try Option Compare Text or Option Compare Binary?
|
| I tried it in VB.NET. 'Option Compare Text' performs a culture-specific
| comparison while 'Option Compare Binary' performs an ordinal comparison.
| With 'Option Compare Text' the expression '"Foo" = ChrW(&HFEFF) & "Foo"'
| will return 'True', which isn't the case if 'Option Compare Binary' is
used.
|
| > Depending on what ChrW(&HFEFF) is, the results you see may be the more
| > correct (between VB6 & .NET).
|
| I didn't compare VB6 to VB.NET in this particular case before posting.
But
| interestingly '"Foo" = ChrW(&HFEFF) & "Foo"' evaluates to 'True' with
| 'Option Compare Text' specified in VB6 while it evaluates to 'False' with
| 'Option Compare Binary'. So the behavior is not really new, but really
| less-known.
|
|
| --
| M S Herfried K. Wagner
| M V P <URL:
http://dotnet.mvps.org/>
| V B <URL:
http://classicvb.org/petition/>
|