#1626 closed Bug (Fixed)
TCPSend( ) only transmits half simplified Chinese characters
Reported by: | txj | Owned by: | Jpm |
---|---|---|---|
Milestone: | 3.3.7.0 | Component: | AutoIt |
Version: | 3.3.6.0 | Severity: | None |
Keywords: | TCPSend | Cc: |
Description
In AutoIt 3.3.6.0, run example in TCPRecv( ) first, then run example in TCPSend( ).
now, input some simplified Chinese characters in "Data for Server" dialog box, only half simplified Chinese characters diaplayed in "My Server" dialog box. see picture.
Attachments (1)
Change History (6)
Changed 15 years ago by txj
comment:1 Changed 15 years ago by Jpm
In fact TCPSend/TCPRecv work with ANSI or binary. Not sure what can be done to have UNICODE chars going thru...
comment:2 follow-up: ↓ 5 Changed 15 years ago by jchd
The following works. From the examples you mention, change the client line 48 into
TCPSend($ConnectedSocket, StringToBinary($szData, 4))
and in the server, change lines 67+:
{{{ ; Try to receive (up to) 2048 bytes
;----------------------------------------------------------------
$recv = TCPRecv($ConnectedSocket, 2048, 1)
; If the receive failed with @error then the socket has disconnected
;----------------------------------------------------------------
If @error Then ExitLoop
; convert from UTF-8 to AutoIt native UTF-16
$recv = BinaryToString($recv, 4)
; Update the edit control with what we have received
}}}
This way, you transmit UTF-8 data. If the client has to send both binary and string data, you need to make the server aware of that so that it doesn't "decode from UTF-8" actual binary data that would instead need be passed verbatim.
comment:3 Changed 15 years ago by Jpm
Thanks jchd,
I will add some doc info about this situation.
comment:4 Changed 15 years ago by Jpm
- Milestone set to 3.3.7.0
- Owner set to Jpm
- Resolution set to Fixed
- Status changed from new to closed
Fixed by revision [5837] in version: 3.3.7.0
comment:5 in reply to: ↑ 2 Changed 15 years ago by txj
Replying to jchd:
The following works. From the examples you mention, change the client line 48 into
TCPSend($ConnectedSocket, StringToBinary($szData, 4))
and in the server, change lines 67+:
{{{ ; Try to receive (up to) 2048 bytes
;----------------------------------------------------------------
$recv = TCPRecv($ConnectedSocket, 2048, 1)
; If the receive failed with @error then the socket has disconnected
;----------------------------------------------------------------
If @error Then ExitLoop
; convert from UTF-8 to AutoIt native UTF-16
$recv = BinaryToString($recv, 4)
; Update the edit control with what we have received
}}}
This way, you transmit UTF-8 data. If the client has to send both binary and string data, you need to make the server aware of that so that it doesn't "decode from UTF-8" actual binary data that would instead need be passed verbatim.
I change code as you mention above, all simplified Chinese characters send OK.
thank you, jchd.
Guidelines for posting comments:
- You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
- In-depth discussions should take place on the forum.
For more information see the full version of the ticket guidelines here.
TCPSend( ) only sends half simplified Chinese characters