Browse Source

buffer: remove raw & raws encoding

As `raw` and `raws` encodings are deprecated for such a long time, and
they both are undocumented, this patch removes the support for those
encodings completely.

Previous discussion: https://github.com/nodejs/node/pull/2829

PR-URL: https://github.com/nodejs/node/pull/2859
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
v5.x
Sakthipriyan Vairamani 10 years ago
parent
commit
5f6579d366
  1. 4
      lib/buffer.js
  2. 12
      src/node.cc
  3. 4
      test/parallel/test-buffer-bytelength.js
  4. 2
      test/parallel/test-file-read-noexist.js

4
lib/buffer.js

@ -194,7 +194,6 @@ Buffer.isEncoding = function(encoding) {
case 'ucs-2': case 'ucs-2':
case 'utf16le': case 'utf16le':
case 'utf-16le': case 'utf-16le':
case 'raw':
return true; return true;
default: default:
@ -260,9 +259,6 @@ function byteLength(string, encoding) {
switch (encoding) { switch (encoding) {
case 'ascii': case 'ascii':
case 'binary': case 'binary':
// Deprecated
case 'raw':
case 'raws':
return len; return len;
case 'utf8': case 'utf8':

12
src/node.cc

@ -1217,18 +1217,6 @@ enum encoding ParseEncoding(const char* encoding,
return BUFFER; return BUFFER;
} else if (strcasecmp(encoding, "hex") == 0) { } else if (strcasecmp(encoding, "hex") == 0) {
return HEX; return HEX;
} else if (strcasecmp(encoding, "raw") == 0) {
if (!no_deprecation) {
fprintf(stderr, "'raw' (array of integers) has been removed. "
"Use 'binary'.\n");
}
return BINARY;
} else if (strcasecmp(encoding, "raws") == 0) {
if (!no_deprecation) {
fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
"Please update your code.\n");
}
return BINARY;
} else { } else {
return default_encoding; return default_encoding;
} }

4
test/parallel/test-buffer-bytelength.js

@ -5,9 +5,9 @@ var assert = require('assert');
var Buffer = require('buffer').Buffer; var Buffer = require('buffer').Buffer;
// coerce values to string // coerce values to string
assert.equal(Buffer.byteLength(32, 'raw'), 2); assert.equal(Buffer.byteLength(32, 'binary'), 2);
assert.equal(Buffer.byteLength(NaN, 'utf8'), 3); assert.equal(Buffer.byteLength(NaN, 'utf8'), 3);
assert.equal(Buffer.byteLength({}, 'raws'), 15); assert.equal(Buffer.byteLength({}, 'binary'), 15);
assert.equal(Buffer.byteLength(), 9); assert.equal(Buffer.byteLength(), 9);
// special case: zero length string // special case: zero length string

2
test/parallel/test-file-read-noexist.js

@ -6,7 +6,7 @@ var fs = require('fs');
var got_error = false; var got_error = false;
var filename = path.join(common.fixturesDir, 'does_not_exist.txt'); var filename = path.join(common.fixturesDir, 'does_not_exist.txt');
fs.readFile(filename, 'raw', function(err, content) { fs.readFile(filename, 'binary', function(err, content) {
if (err) { if (err) {
got_error = true; got_error = true;
} else { } else {

Loading…
Cancel
Save