Android Socket issues with ASCII characters > 128

For the past 2 days I have been trying to send simple 3 character command strings to a motor controller using the Xojo 2024 R2 Android TCPSocket.

Command 1: characters 255 + 0 + 254

Command 2: characters 255 + 0 + 0

Using a data analyser, characters > ASCII 128 are received as 2 bytes

Bytes: 5 [195] [191] [0] [195] [190]
Bytes: 4 [195] [191] [0] [0]

Sending from a desktop application gives the correct result.

Bytes: 3 [255] [0] [254]
Bytes: 3 [255] [0] [0]

Various encoding definitions have been tried including UTF8 and ISOLatin1 but the result is the same. Using String.Chr and String.ChrByte also fails.

Is this a limitation of Android or an issue with the Xojo Android Socket. Any thoughts and ideas would be appreciated.

How? Show us some snippet of code. Chr() for example is wrong, and ChrByte() should be used. More errors can be done… So show us some code of your “string composition” to be sent, let’s see if Xojo have some bug.

If you see “the string” compound correctly in the debugger, but incorrect bytes sent, probably you are correct, a bug may be occurring at the Xojo socket component level.

As for encoding, for a bag of bytes, a Nil one should fit.

Thank you for the prompt response. Here is the code:


sckDT06.Write ChrB( 255) + ChrB( 0) + ChrB( 254)



TCPSocketConnection.Write String.ChrByte( 255) + String.ChrByte( 0) + String.ChrByte( 254)


Ok. Xojo for Android is broken.

Open an Issue Report.

Also, ASCII > 127 does not exists.

Not related to the question, only to the title of the question and understanding between people.

PS: even if you find tables that display their author so-called ASCII Table with value > 127, that beast does not exists (the mapping is different on macOS vs Windows).

Just consider the author intention as “Android Socket issues with 8 bit char codes > 128” (I did) and let’s move on.

If I let move on: “the earth is plate” kind of myth will perpetuates…

In reality, I do not care, but if no one educates (like sometimes you do to me, and I thank you to do that)… people stays in the dark.

Have a good Sunday.

1 Like

Minor issue… Probably what you was trying to teach he knows. But ok.

Have a nice weekend.

“were”, another minor issue.

ASCII, stands for American Standard Code for Information Interchange. It is a 7-bit character code where each individual bit represents a unique character. This page shows the extended ASCII table which is based on the Windows-1252 character set which is an 8 bit ASCII table with 256 characters and symbols. It includes all ASCII codes from standard ASCII, and it is a superset of ISO 8859-1 in terms of printable characters. In the range 128 to 159 (hex 80 to 9F), ISO/IEC 8859-1 has invisible control characters, while Windows-1252 has writable characters. Windows-1252 is probably the most-used 8-bit character encoding in the world.

Hope that helps

Can’t test this but maybe…

var mb as new memoryblock(10)
mb.byte(0) = &hff
mb.byte(1) = &h00
mb.byte(2) = &hfe
mb.size = 3

TCPSocketConnection.write mb

Thank you for the suggestion. Tried it but same result.

255 - 0 - 255

Bytes: 5 [195] [191] [0] [195] [190]

255 - 0 - 0

Bytes: 4 [195] [191] [0] [0]