Pithikos / python-websocket-server

A simple fully working websocket-server in Python with no external dependencies
MIT License
1.13k stars 380 forks source link

Chinese support #73

Closed Yhangzzz closed 3 years ago

Yhangzzz commented 5 years ago

Hello, I found that the library does not support Chinese in use. I can't receive it correctly when receiving Chinese. In the read_next_message(self) function, str() should be used instead of chr() when decoding.

decoded = bytearray() for char in self.read_bytes(payload_length): char ^= masks[len(decoded) % 4] decoded.append(char) decoded = str(decoded, encoding="utf-8") self.server._message_received_(self, decoded)

Pithikos commented 5 years ago

Related: https://github.com/Pithikos/python-websocket-server/issues/72

rainbird commented 3 years ago

decoded = str(decoded, encoding="utf-8")

thk!

Pithikos commented 3 years ago

It's still unclear to me where in the code this goes. Feel free to post a more accurate snippet or make a PR. Closing for now.