Receiving UCS-2 over socket

I’ll skip asking for opinions if UCS-2 is Unicode or not, but at the moment I have a project where I need to send and receive UCS-2 encoded strings over a socket.

In UCS-2 ever char comes across as a “simple” pair of bytes. The closest match from my research is UTF16-LE, but if I define the received string as that it is garbage… If I leave it as UTF-8 I get the extra byte as junk, but since all the characters fit in a single byte anyway, it just appears as a “00” byte and then the character.

I am going to try and isolate some of the potential problem characters and then maybe roll something on my own, but does anyone have experience/resources for UCS-2 in Xojo?

Did you try UTF16 BigEndian?
Especially a NULL byte before characters would point to that byte order.

Additional question: Is there a function for escaping UTF16 into JavaScript Unicode Escape Sequences? Which would be “\u00E4” for “”?

Thank you - I already wrote a small function in Xojo that escapes UTF16BE. Basically put UTF16BE in a Memory Block and then walk over every Byte pair. If somebody needs it, I can post that 15 lines.

Just I was hoping that there is a plugin function around, which does this more efficiently.