Hi,
Recently(in Feb) there is a change[1] in test-buffer.js makes me wonder what's
the proper value of Buffer._charsWritten. The doc says "The number of
characters written (which may be different than the number of
bytes written) is set in Buffer._charsWritten", and I assume it means
characters consumed during decoding process from the input string.
At test/simple/test-buffer.js:689, the test assert value is changed from 6 to
4, I am trying to understand why.
buf.write('123456', 'base64');
assert.equal(Buffer._charsWritten, 4);
buf.write('00010203040506070809', 'hex');
assert.equal(Buffer._charsWritten, 18);
As the total characters used to decode 4 octets are all six characters. A
well-format base64 encoded string probably should include 2 paddings and be 8
characters(multiple of 4).
If we consider only 4 characters are valid and used to decode, the result
octets written would be 3 instead of 4. The buf.write() does write 4 octets and
returns 4.
Should this be considered a bug in test or is there a better explanation? Or
perhaps I misunderstood what _charsWritten means?
[1]
https://github.com/joyent/node/commit/f101f7c9babb31f077c78b52de7cc45ad687f57e#test/simple/test-buffer.js
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en