Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix utf8 issue

  • Loading branch information...
commit 49a6352b73ab50a3b4639abd733da31c632abead 1 parent fd6979a
@Jae Jae authored
Showing with 10 additions and 3 deletions.
  1. +10 −3 node_modules/thrift/protocol.js
View
13 node_modules/thrift/protocol.js
@@ -123,9 +123,16 @@ TBinaryProtocol.prototype.writeDouble = function(dub) {
this.trans.write(BinaryParser.fromDouble(dub));
}
-TBinaryProtocol.prototype.writeString = function(str) {
- this.writeI32(str.length);
- this.trans.write(str);
+TBinaryProtocol.prototype.writeString = function(arg) {
+ if (typeof(arg) === 'string') {
+ this.writeI32(Buffer.byteLength(arg, 'utf8'))
+ this.trans.write(arg, 'utf8');
+ } else if (arg instanceof Buffer) {
+ this.writeI32(arg.length)
+ this.trans.write(arg);
+ } else {
+ throw new Error('writeString called without a string/Buffer argument: ' + arg)
+ }
}
TBinaryProtocol.prototype.readMessageBegin = function() {
Please sign in to comment.
Something went wrong with that request. Please try again.