You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Jacques Le Roux <ja...@les7arts.com> on 2024/10/09 16:51:16 UTC
Should we use toLowerCase(Locale.getDefault()) everywhere?
Hi,
By chance, I stumbled upon this Java doc about toLowerCase()
Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale
independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish locale
returns "t\u005Cu0131tle", where '\u005Cu0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale insensitive
strings, use toLowerCase(Locale.ROOT).
As it's configurable in OFBiz we prefer to use Locale.getDefault() rather than Locale.ROOT.
For consistency I see no reason to not change all toLowerCase() to toLowerCase(Locale.getDefault()). Even if the context does not really need it.
Opinions?
TIA
Jacques
Re: Should we use toLowerCase(Locale.getDefault()) everywhere?
Posted by Jacques Le Roux <ja...@les7arts.com>.
As it's said, ain't broke, don't fix it
I'll do nothing :)
Jacques
Le 10/10/2024 à 09:53, Jacques Le Roux a écrit :
> Thanks Florian, I'll have a look
>
> Jacques
>
> Le 10/10/2024 à 08:34, Florian Motteau a écrit :
>> Reminds me of this : https://issues.apache.org/jira/browse/OFBIZ-12660
>>
>> Le 09/10/2024 à 18:51, Jacques Le Roux a écrit :
>>> Hi,
>>>
>>> By chance, I stumbled upon this Java doc about toLowerCase()
>>>
>>> Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale
>>> independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish
>>> locale returns "t\u005Cu0131tle", where '\u005Cu0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale
>>> insensitive strings, use toLowerCase(Locale.ROOT).
>>>
>>> As it's configurable in OFBiz we prefer to use Locale.getDefault() rather than Locale.ROOT.
>>>
>>> For consistency I see no reason to not change all toLowerCase() to toLowerCase(Locale.getDefault()). Even if the context does not really need it.
>>>
>>> Opinions?
>>>
>>> TIA
>>>
>>> Jacques
>>>
>>>
>>>
Re: Should we use toLowerCase(Locale.getDefault()) everywhere?
Posted by Jacques Le Roux <ja...@les7arts.com>.
Thanks Florian, I'll have a look
Jacques
Le 10/10/2024 à 08:34, Florian Motteau a écrit :
> Reminds me of this : https://issues.apache.org/jira/browse/OFBIZ-12660
>
> Le 09/10/2024 à 18:51, Jacques Le Roux a écrit :
>> Hi,
>>
>> By chance, I stumbled upon this Java doc about toLowerCase()
>>
>> Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale
>> independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish locale
>> returns "t\u005Cu0131tle", where '\u005Cu0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale insensitive
>> strings, use toLowerCase(Locale.ROOT).
>>
>> As it's configurable in OFBiz we prefer to use Locale.getDefault() rather than Locale.ROOT.
>>
>> For consistency I see no reason to not change all toLowerCase() to toLowerCase(Locale.getDefault()). Even if the context does not really need it.
>>
>> Opinions?
>>
>> TIA
>>
>> Jacques
>>
>>
>>
Re: Should we use toLowerCase(Locale.getDefault()) everywhere?
Posted by Florian Motteau <fl...@motteau-martins.net>.
Reminds me of this : https://issues.apache.org/jira/browse/OFBIZ-12660
Le 09/10/2024 à 18:51, Jacques Le Roux a écrit :
> Hi,
>
> By chance, I stumbled upon this Java doc about toLowerCase()
>
> Note: This method is locale sensitive, and may produce unexpected
> results if used for strings that are intended to be interpreted locale
> independently. Examples are programming language identifiers, protocol
> keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish
> locale returns "t\u005Cu0131tle", where '\u005Cu0131' is the LATIN
> SMALL LETTER DOTLESS I character. To obtain correct results for locale
> insensitive strings, use toLowerCase(Locale.ROOT).
>
> As it's configurable in OFBiz we prefer to use Locale.getDefault()
> rather than Locale.ROOT.
>
> For consistency I see no reason to not change all toLowerCase() to
> toLowerCase(Locale.getDefault()). Even if the context does not really
> need it.
>
> Opinions?
>
> TIA
>
> Jacques
>
>
>