ngx.req.udp_socket 接收到中文 编码为GBK 或者unicode 时 出现乱码?

44 views
Skip to first unread message

fan yang

unread,
Jul 12, 2020, 5:07:34 AM7/12/20
to openresty
 利用 udp_socket 接收 中文的GBK 或者unicode 编码,得到的中文会出现乱码的情况
  local sock = assert(ngx.req.udp_socket(true))
  local one, err, part = sock:receive()

接收中文为测试数据
GBK的乱码为

unicode的乱码为

Nick Xiao

unread,
Jul 13, 2020, 1:30:10 AM7/13/20
to open...@googlegroups.com
这个是 log 显示的问题. 一般默认会以 utf8 来显示 error.log. 
openresty 不会管 encoding. 数据都可以认为是按 binary 来处理的. 

On Jul 12, 2020, at 5:07 PM, fan yang <yangf...@gmail.com> wrote:

 利用 udp_socket 接收 中文的GBK 或者unicode 编码,得到的中文会出现乱码的情况
  local sock = assert(ngx.req.udp_socket(true))
  local one, err, part = sock:receive()

接收中文为测试数据
GBK的乱码为
<Auto Generated Inline Image 1.png>
unicode的乱码为
<Auto Generated Inline Image 2.png>

--
--
邮件来自列表“openresty”,专用于技术讨论!
订阅: 请发空白邮件到 openresty...@googlegroups.com
发言: 请发邮件到 open...@googlegroups.com
退订: 请发邮件至 openresty+...@googlegroups.com
归档: http://groups.google.com/group/openresty
官网: http://openresty.org/
仓库: https://github.com/agentzh/ngx_openresty
教程: http://openresty.org/download/agentzh-nginx-tutorials-zhcn.html
---
您收到此邮件是因为您订阅了Google网上论坛上的“openresty”群组。
要退订此群组并停止接收此群组的电子邮件,请发送电子邮件到openresty+...@googlegroups.com
要在网络上查看此讨论,请访问https://groups.google.com/d/msgid/openresty/02ce03b0-c1bf-44f6-a7ef-7dd8ca77de37o%40googlegroups.com
<Auto Generated Inline Image 1.png><Auto Generated Inline Image 2.png>

Reply all
Reply to author
Forward
0 new messages