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

如何在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
    
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题