@@ -403,7 +403,6 @@ function readFunc(f, arrayLen, off, datalen) {
403403 off += datalen ;
404404 }
405405 return res ;
406- d
407406}
408407
409408function decodeObject ( buf , offset , dsDecode ) {
@@ -415,7 +414,7 @@ function decodeObject(buf, offset, dsDecode) {
415414 for ( i = 0 ; i < len ; i ++ ) {
416415 info = dsDecode [ i ] ;
417416 off = info [ 0 ] + offset ;
418- key = info [ 3 ] ;
417+ var key = info [ 3 ] ;
419418 var arrayLen = info [ 5 ] ;
420419 var values = [ ] ;
421420 for ( var arri = 0 ; arri < arrayLen ; arri ++ ) {
@@ -433,7 +432,7 @@ function decodeObject(buf, offset, dsDecode) {
433432 case DataType . int64 :
434433 var high = buf . readUInt32LE ( off ) ;
435434 var low = buf . readUInt32LE ( off + 4 ) ;
436- values . push ( ( high << 8 ) | low ) ;
435+ values . push ( low * 0x100000000 + high ) ;
437436 break ;
438437 case DataType . uint8 :
439438 values . push ( buf . readUInt8 ( off ) ) ;
@@ -456,7 +455,8 @@ function decodeObject(buf, offset, dsDecode) {
456455 break ;
457456 case DataType . string : {
458457 //values = buf.toString(undefined, off, off+info[1]-1 );
459- values . push ( iconv . decode ( buf . slice ( off , off + info [ 1 ] - 1 ) , 'gb2312' ) ) ;
458+ var val = iconv . decode ( buf . slice ( off , off + info [ 1 ] - 1 ) , info [ 4 ] ) ;
459+ values . push ( val . replace ( / \0 [ \s \S ] * / g, '' ) ) ;
460460 }
461461 break ;
462462 case DataType . object : {
@@ -499,9 +499,11 @@ function encodeObject(data, dsLen, dsEncode) {
499499 msgBuf . writeInt32LE ( x , off ) ;
500500 break ;
501501 case DataType . int64 :
502- msgBuf . writeUInt32LE ( x >> 8 , off ) ; //write the high order bits (shifted over)
503- off += 4 ;
504- msgBuf . writeUInt32LE ( x & 0x00ff , off ) ; //write the low order bits
502+ let high = ~ ~ ( x / 0xFFFFFFFF ) ;
503+ let low = ( x % 0xFFFFFFFF ) - high ;
504+
505+ msgBuf . writeUInt32LE ( low , off ) ;
506+ msgBuf . writeUInt32LE ( high , ( off + 4 ) ) ;
505507 break ;
506508 case DataType . uint8 :
507509 msgBuf . writeUInt8 ( x , off ) ;
@@ -544,8 +546,3 @@ function encodeObject(data, dsLen, dsEncode) {
544546
545547 return msgBuf ;
546548}
547-
548-
549-
550-
551-
0 commit comments