kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
752 stars 272 forks source link

中文出现乱码 #174

Closed hsxyhao closed 4 years ago

hsxyhao commented 4 years ago

接收到中文数据出现了乱码: 想通过DataReceived来解决乱码问题,但是DataReceived一直没有接收数据,请教一下该怎么样解决乱码这个问题,还是说服务器传过来的数据有问题(ps: 使用Java的话没有乱码问题)!

kerryjiang commented 4 years ago

How do you decode binary data to string? Which encoding do you use?

hsxyhao commented 4 years ago

How do you decode binary data to string? Which encoding do you use?

I'm connected to someone else's websocket server. I don't know which encoding they use (maybe GBK). Can I use DataReceived to solve the problem? Sorry, my poor English.

kerryjiang commented 4 years ago

What you can get from the event DataReceived is binary data, right? You should use the same encoding which is used by the server. How do you convert the binary data to string?

hsxyhao commented 4 years ago

What you can get from the event DataReceived is binary data, right? You should use the same encoding which is used by the server. How do you convert the binary data to string?

yes, i know. but the DataReceived event don't invoke. Are there some docs about DataReceived here? I don't know how to use DataReceived. thank you.

kerryjiang commented 4 years ago

But how do you know "中文出现乱码"?

hsxyhao commented 4 years ago

But how do you know "中文出现乱码"?

the result contains "��" character, thank you for answer, I will look for another solution.