How to write Chinese to a specified fd by cPP network programming

normally, the functions used in network programming are
ssize_t read (int fd, void * buf, size_t nbyte)
ssize_t write (int fd, const void * buf, size_t nbytes)
to transmit byte by byte.

but usually, a word in Chinese accounts for 2 to 3 bytes, so garbled may occur in the process of transmission.

so I would like to ask, how should this problem be solved?


first of all, tcp ensures sequential delivery and data correctness in transmission, so it is impossible to cause data errors.

it should be your server side and client side decoding problem
I guess you are the problem encountered by server side on linux and client side on win.
you can check whether the encodings match through the
linux

win
command lines.
in addition, you should also pay attention to the size of the end.


is not a byte-by-byte separate transmission, it is continuous. One time is to transfer the number of bytes you give. So there will be no 3-byte separate transmission of one Chinese you said. Pay attention to the coding when displaying, and the codes on both sides should be the same, otherwise it will also be garbled

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bdd54c-306c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bdd54c-306c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?