Modify

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#1626 closed Bug (Fixed)

TCPSend( ) only transmits half simplified Chinese characters

Reported by: txj Owned by: J-Paul Mesnage
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)

TCPSendBug.JPG (197.5 KB ) - added by txj 16 years ago.
TCPSend( ) only sends half simplified Chinese characters

Download all attachments as: .zip

Change History (6)

by txj, 16 years ago

Attachment: TCPSendBug.JPG added

TCPSend( ) only sends half simplified Chinese characters

comment:1 by J-Paul Mesnage, 16 years ago

In fact TCPSend/TCPRecv work with ANSI or binary. Not sure what can be done to have UNICODE chars going thru...

comment:2 by jchd, 16 years ago

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 by J-Paul Mesnage, 16 years ago

Thanks jchd,
I will add some doc info about this situation.

comment:4 by J-Paul Mesnage, 16 years ago

Milestone: 3.3.7.0
Owner: set to J-Paul Mesnage
Resolution: Fixed
Status: newclosed

Fixed by revision [5837] in version: 3.3.7.0

in reply to:  2 comment:5 by txj, 16 years ago

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.

Modify Ticket

Action
as closed The owner will remain J-Paul Mesnage.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.