douche5961
2017-01-21 22:49
浏览 263
已采纳

如何在golang中以UTF-8编码gob?

I am using gob.NewEncoder to encode string message msg but need to do it in utf-8.

err= gob.NewEncoder(conn).Encode(msg)

I am getting warning in Ruby receiver (Logstash) saying that Received an event that has a different character encoding than you configured ...:expected_charset=>"UTF-8"

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dtw52353 2017-01-22 00:20
    已采纳

    When you call Encode(msg), you are not sending UTF-8 plain text.

    To send plain text:

    conn.Write([]byte(msg)) // suppose msg is string
    
    点赞 打赏 评论

相关推荐 更多相似问题