Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#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)

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

Download all attachments as: .zip

Change History (6)

Changed 9 years ago by txj

TCPSend( ) only sends half simplified Chinese characters

comment:1 Changed 9 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: Changed 9 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 9 years ago by Jpm

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

comment:4 Changed 9 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 9 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.

Add Comment

Modify Ticket

Action
as closed The owner will remain Jpm.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.