开发者

erlang send socket cyrillic data

开发者 https://www.devze.com 2023-02-05 06:24 出处:网络
I\'m trying to send data from the server written in Erlang: gen_tcp:send(Socket, \"Server connection refused \\r\\n\").

I'm trying to send data from the server written in Erlang:

gen_tcp:send(Socket, "Server connection refused \r\n").

It's ok. But when I try to send data with non-latin symbols, e. g. cyrillic, I see the开发者_如何转开发 error report. For example if i use:

gen_tcp:send(Socket, "Привет \r\n").

Instead of string I see error report. How do I send a string with non-latin characters via TCP socket from Erlang?


Try this:

8> unicode:characters_to_binary("пириуэт да").
<<208,191,208,184,209,128,208,184,209,131,209,141,209,130,
  32,208,180,208,176>>
9>
0

精彩评论

暂无评论...
验证码 换一张
取 消