Bug? ToLowerCase does not work correctly for the Turkish language

alwaysbusy

Expert
Licensed User
Longtime User
Searching for a bug in my BANano library, I discovered a bug in the .toLowerCase() for the letter I in the Turkish language.

In the Turkish locale, the Unicode LATIN CAPITAL LETTER I becomes a LATIN SMALL LETTER DOTLESS I. That’s not a lowercase “i”.

To test:
B4X:
#VirtualMachineArgs: -Duser.language=tr

B4X:
Dim s As String = "IF"
If s.toLowerCase = "if" Then '  the s.toLowerCase returns ıf (no dot on the i)
        Log("True")
Else
        Log("False")
End If

Result:
returns False

Possible solution, being able to add a Locale:
B4X:
.toLowerCase2(Locale.ROOT)

Edit: the same goes for .toUpperCase()

Alwaysbusy
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can call this method when the app starts to set the default locale to US.
B4X:
Private Sub SetDefaultLocaleToUS
    Dim jo As JavaObject
    jo.InitializeStatic("java.util.Locale").RunMethod("setDefault", Array(jo.GetField("US")))
End Sub

If you want to keep using the native locale for date related methods then set the date format before calling this method.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…