lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niels Kühnel (JIRA) <j...@apache.org>
Subject [Lucene.Net] [jira] [Commented] (LUCENENET-420) String.StartsWith has culture in it.
Date Sun, 29 May 2011 10:38:47 GMT

    [ https://issues.apache.org/jira/browse/LUCENENET-420?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13040780#comment-13040780
] 

Niels Kühnel commented on LUCENENET-420:
----------------------------------------

I think that the WildcardTermEnum.TermCompare should just compare the string chars without
any special local considerations. It's confusing that the thread's culture may cause issues
like this.
 
If String.StartWith("...", StringComparison.InvariantCulture) was default a special tokenizer
could be used if you actually wanted some special localized behavior.

Again, thanks for looking at it.

> String.StartsWith has culture in it.
> ------------------------------------
>
>                 Key: LUCENENET-420
>                 URL: https://issues.apache.org/jira/browse/LUCENENET-420
>             Project: Lucene.Net
>          Issue Type: Bug
>          Components: Lucene.Net Core
>    Affects Versions: Lucene.Net 2.9.2, Lucene.Net 2.9.4, Lucene.Net 3.x
>         Environment: .NET under (at least) da-DK culture
>            Reporter: Niels Kühnel
>             Fix For: Lucene.Net 2.9.2, Lucene.Net 2.9.4, Lucene.Net 3.x
>
>   Original Estimate: 4h
>  Remaining Estimate: 4h
>
> I've been hunting a weird bug for a long time. I finally found it's cause.
> I'm Danish, thus my .NET culture is "da-DK". In this culture "Gaard", doesn't start with
"Ga" because it thinks that "aa" is "å" (in Danish it was before 1948).
> That gives some unexpected results when doing prefix queries.
> The solution is to add StringComparison.InvariantCulture in all StartsWith comparisons.
> To verify my claim, try running:
> Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("da-DK");
> Assert.IsFalse("Gaard".StartsWith("Ga"));
> Assert.IsTrue("Gaard".StartsWith("Ga", StringComparison.InvariantCulture));
> Cheers,
> Niels Kühnel

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message