thrift的中文编码处理

thrift处理中文,传输中文中可能出现错误。

具体需要修改thrift中源码。

修改TBinaryProtocol.py中的代码:

  def writeString(self, str):
    if type(str) is unicode:
      str = str.encode('utf-8')
    self.writeI32(len(str))
    self.trans.write(str)

主要加入了str.encode("utf-8")功能

原文地址:https://www.cnblogs.com/CLTANG/p/2708693.html