File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1203,7 +1203,6 @@ ssize_t DecodeWrite(char *buf,
12031203
12041204 for (size_t i = 0 ; i < buflen; i++) {
12051205 unsigned char *b = reinterpret_cast <unsigned char *>(&twobytebuf[i]);
1206- assert (b[1 ] == 0 );
12071206 buf[i] = b[0 ];
12081207 }
12091208
Original file line number Diff line number Diff line change @@ -505,3 +505,18 @@ assert.equal(0x6f, z[1]);
505505var b = new SlowBuffer ( 10 ) ;
506506b . write ( 'あいうえお' , 'ucs2' ) ;
507507assert . equal ( b . toString ( 'ucs2' ) , 'あいうえお' ) ;
508+
509+ // Binary encoding should write only one byte per character.
510+ var b = Buffer ( [ 0xde , 0xad , 0xbe , 0xef ] ) ;
511+ var s = String . fromCharCode ( 0xffff ) ;
512+ b . write ( s , 0 , 'binary' )
513+ assert . equal ( 0xff , b [ 0 ] ) ;
514+ assert . equal ( 0xad , b [ 1 ] ) ;
515+ assert . equal ( 0xbe , b [ 2 ] ) ;
516+ assert . equal ( 0xef , b [ 3 ] ) ;
517+ s = String . fromCharCode ( 0xaaee ) ;
518+ b . write ( s , 0 , 'binary' )
519+ assert . equal ( 0xee , b [ 0 ] ) ;
520+ assert . equal ( 0xad , b [ 1 ] ) ;
521+ assert . equal ( 0xbe , b [ 2 ] ) ;
522+ assert . equal ( 0xef , b [ 3 ] ) ;
You can’t perform that action at this time.
0 commit comments