User bio
404 bio not found
Member since Mar 8, 2021
Replies:

UTF8 has to be set to the socket translation table:

Set sock.TranslationTable="UTF8"

and the solution in objectscript for the Java function:

DataOutputStream out = new DataOutputStream(socket.getOutputStream());

out.writeUTF(str);

is the following:

Do sock.Write($$setShort($Length(str)), 0, .sc)

Do sock.Write(str, 0, .sc)

setShort(num) {
Quit $Reverse($ZWChar(num))
}

Thank you, Robert.

I read about your examples. My problem is more related to the write command. I do not know if there is a possibility in Cache to create the same function of the following:

JAVA (DataOutputStream->writeUTF)

Writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the modified UTF-8 encoding for the character. If no exception is thrown, the counter written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of str, and at most two plus thrice the length of str.

or

PHP (pack function)

write(pack('n', $length).$utfString);

Certifications & Credly badges:
Sorin has no Certifications & Credly badges yet.
Global Masters badges:
Sorin has no Global Masters badges yet.
Followers:
Sorin has no followers yet.
Following:
Sorin has not followed anybody yet.