Don't do something like this:
or this
It works only with English and a few other languages.
The isLetter method form java returns true if the character is a letter in Chinese, German, Arabic, or another language. https://docs.oracle.com/javase/tutorial/i18n/text/charintro.html
https://docs.oracle.com/javase/tutorial/i18n/text/charintro.html
Library: JavaObject
Example:
B4X:
'This code is WRONG!
Sub IsLetter(L As String) As Boolean
return ( "ABCDEFGHIJKLMNOPQRSTUVWXYZ".Contains( L.ToUpperCase) )
End Sub
B4X:
'Visual Basic Code
'This code is WRONG!
Function IsLetter(strValue As String) As Boolean
Dim intPos As Integer For intPos = 1 To Len(strValue)
Select Case Asc(Mid(strValue, intPos, 1))
Case 65 To 90, 97 To 122
IsLetter = True
Case Else
IsLetter = False
Exit For
End Select
Next
End Function
The isLetter method form java returns true if the character is a letter in Chinese, German, Arabic, or another language. https://docs.oracle.com/javase/tutorial/i18n/text/charintro.html
https://docs.oracle.com/javase/tutorial/i18n/text/charintro.html
Library: JavaObject
B4X:
'check if string are letters
Sub isLetters( Text As String ) As Boolean
Dim ret As Boolean
For i=0 To Text.Length -1
ret = isLetter( Text.CharAt(i))
If ret = False Then Return False
Next
Return True
End Sub
'check if aChar is a letter
Sub isLetter( aChar As Char) As Boolean
Dim jo As JavaObject
Return jo.InitializeStatic("java.lang.Character").RunMethod( "isLetter", Array( aChar))
End Sub
Example:
B4X:
Dim s As String = "aüßáàâăąæåã"
Log( isLetters( s)) 'return true