Page 1 of 1

Sending arrays through sockets, from different platforms and different system languages

Posted: Tue Jul 24, 2018 5:11 pm
by trevix
I went back to an App of mine, Tcal, started with LC 5.5, and developed now with LC 8.1.10.

The App is made of a standalone server and several standalone clients.
Each clients writes to the server and the server respond to each clients.
Clients can be OSX or Windows. The same for the server. Each one can also run with different System settings (different part of the globe) with accented chars, etc.

It was working fine, but now I decided to change the the data format that is transmitted through sockets, going from "|" delimited text to multi-key arrays (like tArray["some"]["other"]), because of much easier internal handling.

I need suggestions on how is better to pack the data that get sent trough sockets.
I use to handle the different platforms simply using a "IsoToMac" and "MacToIso" (everything arrived as Mac formatted text and then eventually converted) but now with array, things get a little more complex.
Because of the use of array, I need ArrayEncode and ArrayDecode before transmission and on receive.
(I may also have to "Base64Encode" and "Base64Decode" the data, to ensure safety).
With text I could just Base64Encode(IsoToMac(TheData)) everything before transmission.
With Array, while I can ArrayEncode and Base64Encode each array on the transmit script, I must decide where in my scripts to do the IsoToMac(each key and content of the array)

Any suggestion on how to deal with these problems? Speed problems?
I tried to read about Unicode (http://livecode.byu.edu/unicode/unicodeInRev.php) but i simply don't grasp it (sigh)
Trevix

Re: Sending arrays through sockets, from different platforms and different system languages

Posted: Tue Jul 24, 2018 6:21 pm
by trevix
I just found out that I cannot do this (on windows it does not work):

Code: Select all

 put ArrayEncode(tArray,"7.0") into tText
put IsoToMac(tText) into tText
put MacToIso(tText) into tText
  put ArrayDecode(tText) into tFinalArray
So i guess there is not other mean that go with a repeat for each key and each content

Re: Sending arrays through sockets, from different platforms and different system languages

Posted: Wed Jul 25, 2018 5:16 pm
by jacque
ArrayEncode changes the text to binary. Do the ISO conversion first, then ArrayEncode it. Reverse the process to decode.

But LC now handles unicode automatically so you shouldn't need to use ISO conversions at all.