I am trying to send a command via a tcp socket. this command is received by the receiver (external device) as ansi text.
How can I implement this?
B4X:
Private Sub send_button_Click
If Astreams.IsInitialized = False Then Return
If send_edit.Text.Length > 0 Then
Dim sNewLine As String
sNewLine = send_edit.text & Chr(13)
Dim buffer() As Byte
buffer = sNewLine.GetBytes("ANSI")
Astreams.Write(buffer)
ToastMessageShow("Sending:" & sNewLine,False)
Log("Connect: send_button_Click | send: " & send_edit.Text)
End If
End Sub
My first thought would be to use a listed encoding like:
"ISO-8859-1" = 8-bit 1:1 encoding
"windows-1252" = old most common web encoding
"UTF-8" = new most common web encoding (Char values > ASCII encode to more-than-one byte)
B4X:
Dim bc As ByteConverter
Dim SE() As String = bc.SupportedEncodings
For Each E As String In SE
Log(E)
Next
thank you very much. Yes, I used ANSI by mistake. Now it works - with "ISO-8859-1". Thanks for the tip.
But I had also initialized the stream with "InitializePrefix". That didn't work or caused errors. Now the connection works!