nsqio / go-nsq

The official Go package for NSQ
MIT License
2.59k stars 444 forks source link

when i use go for producer and php for consumer ,special or chinese character convert to null #252

Closed bujike closed 4 years ago

bujike commented 5 years ago

It was before when i user php client for producer and consumer and It was normal,but recently, i decide to use go-nsq for producer and php client for consumer . I found special character like '【】' and chinese character can not be obvious normaly. anyone have meet the same question . My producer code is like this

data = map[string]interface{}{ "chinese_name" : "张三", "english_name" :"hawk", } body := []map[string]interface{}{data} params := map[string]interface{}{ "args": body, } dataByte, err := json.Marshal(params) if err != nil { panic(err) } p.Publish("wechat_tpl_send", dataByte)

ploxiln commented 4 years ago

nsq treats the message body as bytes, it is not involved in encoding or decoding the message body. Go's json.Marshal() will encode the json as utf8, maybe there is some issue in the php consumer, maybe some charset/encoding mixup (utf8 vs utf16-le vs GBK vs whatever).