Android Question Determination for Unicode cherecters

emexes

Expert
Licensed User
I thought strings in Android were always Unicode, in which case this will do it:
B4X:
Dim StringHaveUnicodeCharacterFlag As Boolean = (TestString.Length <> 0)
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
but more likely you are trying to determine if a string contains a particular character or substring, in which case the .Contains string function might do the job:
B4X:
If PlayerName.Contains("oo") Then
    Score = HighScore + 10    'or whatever you want to do when the player's name has lowercase double-o in it
End If
 
Upvote 0

emexes

Expert
Licensed User
or are you trying to find out if the string contains any non-ASCII characters, ie characters that need specific character maps or multiple bytes to encode?

eg "Nineteen characters" will generally encode to 19 bytes but "15 characters šŸ˜‡" will be longer than 15 bytes because the "smiling face with halo" character is Chr(128519) which is going to need at least three bytes to represent it, because a single byte can only hold 256 different values, usually 0..255 for oldtimers, or -128 to 127 for newbies.
 
Upvote 0
Top