iOS Question iOS soft keyboard - Can I determine the keyboard type?

Arf

Well-Known Member
Licensed User
Longtime User
Having a struggle here.. I am capturing iOS onscreen keyboard presses by capturing the characters that appear in a textview, converting those characters to ascii codes and sending the ascii codes to another device which is connected to a Windows PC and emulates a keyboard, which then calculates which keyboard key combinations need to be sent to the PC in order to replicate the character that was typed in to the soft iOS keyboard.

Works OK for plain ascii. I have a problem with the £ key though, of course since it is not in the normal ascii table.
B4i interprets the values as "new char: £, codepoint: 163"
string.GetBytes("utf8") doesn't convert this into anything. I don't know if there is any alternative encoding I can use which does.

Anyhow, the main problem I have is firstly in trying to maintain consistent encodings throughout this chain.

I also want this to work in different languages though, which may not be possible.
Here is my question:
I am wondering if it is possible to programmatically determine some properties of the iOS soft keyboard, so that I can know what locale it is in or something like that, so I can change the various encodings down the chain and set the keyboard emulator to use that local of keyboard?

In most cases the user would of course have their phone and their PC set to the same language.

Thanks, my brain hurts
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
163 is the Unicode code point of this character. It has nothing to do with encoding.

If you want to handle more complicated characters such as emojies then the best encoding is UTF-32LE.
And you can get the code point value with:
B4X:
Dim cp As Int = BytesToInt("£".GetBytes("UTF-32LE"), 0)


Private Sub BytesToInt (Bytes() As Byte, StartIndex As Int) As Int
    Dim cp As Int
    For i = 0 To 3
        cp = Bit.Or(cp, Bit.ShiftLeft(Bit.And(0xff, Bytes(i + StartIndex)), 8 * i))
    Next
    Return cp
End Sub
 
Upvote 0

Arf

Well-Known Member
Licensed User
Longtime User
For people outside the UK - particularly US but also any other location.. I am interested in what your iphone soft keyboard looks like.
I am just looking to know how the appearance differs to mine. My 3 input options are shown below:
1727285021444.png
1727285042308.png
1727285072640.png


thanks
 
Upvote 0
Top