Jump to content

TCP functions with unicode characters


Recommended Posts

I'm trying to send Hebrew characters in TCP and then add the data to a tree view.

server:

TCPStartup()

$listen = TCPListen(@IPAddress1,2000)

GUICreate("")
$tree = GUICtrlCreateTreeView(0, 0, 300, 300)
GUISetState()

While 1
    $accept = TCPAccept($listen)
    If $accept <> -1 Then
        ExitLoop
    EndIf
    
    
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd
ToolTip("accepted")

While 1
    $tcpRecv = TCPRecv($accept, 1000000,1)
    If $tcpRecv <> "" Then
        ExitLoop
    EndIf
    
    
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd
ToolTip("received")

GUICtrlCreateTreeViewItem("1: " & BinaryToString($tcpRecv,1),$tree)
GUICtrlCreateTreeViewItem("2: " & BinaryToString($tcpRecv,2),$tree)
GUICtrlCreateTreeViewItem("3: " & BinaryToString($tcpRecv,3),$tree)
GUICtrlCreateTreeViewItem("4: " & BinaryToString($tcpRecv,4),$tree)

GUICtrlCreateTreeViewItem("עברית: שדגשדג",$tree) ;just to see if Hebrew characters actually display
TCPCloseSocket($accept)
While 1
    If GUIGetMsg() = -3 Then
        Exit
    EndIf
WEnd

TCPShutdown()

client:

TCPStartup()
$con = TCPConnect(@IPAddress1,2000)
If @error Then
    MsgBox(0,0,"could not connect")
    Exit
EndIf

TCPSend($con,Binary("א ב ג ד ה ו א ב ג ד ה ו"))
;TCPSend($con,Binary("asdasd"))
Sleep(100)
TCPShutdown()

Result:

Posted Image

Any suggestions?

Edited by Info
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...