buffer: strip high bits when converting to ascii
authorBen Noordhuis <info@bnoordhuis.nl>
Thu, 6 Dec 2012 04:13:14 +0000 (05:13 +0100)
committerisaacs <i@izs.me>
Fri, 8 Mar 2013 22:42:15 +0000 (14:42 -0800)
commit96a314b68b19277cc71ccac06b6517956b8f8a22
tree52af2de1ca63cd8f8c4dc1a45f7506dd6ee53228
parent632b7d8750a93fbfea2c810ae123be41831dd602
buffer: strip high bits when converting to ascii

Consider the following example:

  console.log(Buffer('ú').toString('ascii'));

Before this commit, the contents of the buffer was used as-is and hence it
prints 'ú'.

Now, it prints 'C:'. Perhaps not much of an improvement but it conforms to what
the documentation says it does: strip off the high bits.

Fixes #4371.
doc/api/buffer.markdown
src/node_buffer.cc
test/simple/test-buffer-ascii.js [new file with mode: 0644]