0

I created a Client with Java and a Server with Python. The Java client receive data using readUTF() of the class DataInputStream. My problem is that the function readUTF() expects a modified version of 'utf-8' that I don't know how to generate in the (Python) server side.

  • 1
    Why do you not simply use regular utf-8 for the interface? Instead of readUTF() you should use a stream-reader class with strings and characters instead. – Stefan Feb 09 '20 at 11:29
  • Welcome to SO! I think you could improve your chances of getting an answer with a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) – DCTID Feb 12 '20 at 04:00

2 Answers2

0

You will have to manually encode() your python string with the appropriate format.

How to convert a string to utf-8 in Python

  • My problem is not with encoding into utf-8 I can just send something like b'test', my problem is with the specific modified version of utf-8 that readUTF() function expects... – רועי כרמי Feb 09 '20 at 17:53
0

I got it!. Using the function read() of the class DataInputStream do work. The problem was that I initialized the destination buffer like this: byte[] ans = {}, instead of allocating some bytes. Thanks for everyone!