Howto set PHP socket_write and socket_read character encoding?
character-encoding, php, sockets
Solution
These functions transmit the string unconverted (i.e. byte by byte), so you cannot set a character encoding. But this means as well, that you don't have to. You'll have the exact same string on the other side with the exact same encoding.
You can convert it before sending/after receiving the string using `mb_convert_encoding()`.
Problem
I'm writing a PHP server and the client is sending data in a specific character encoding. Now, I want to tell the server to read and write data in this same character encoding set. How should I specify the character encoding set for PHP's socket_read and socket_write methods?