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>
This commit is contained in:
parent
9aa6a437cd
commit
5f6579d366
@ -194,7 +194,6 @@ Buffer.isEncoding = function(encoding) {
|
||||
case 'ucs-2':
|
||||
case 'utf16le':
|
||||
case 'utf-16le':
|
||||
case 'raw':
|
||||
return true;
|
||||
|
||||
default:
|
||||
@ -260,9 +259,6 @@ function byteLength(string, encoding) {
|
||||
switch (encoding) {
|
||||
case 'ascii':
|
||||
case 'binary':
|
||||
// Deprecated
|
||||
case 'raw':
|
||||
case 'raws':
|
||||
return len;
|
||||
|
||||
case 'utf8':
|
||||
|
12
src/node.cc
12
src/node.cc
@ -1217,18 +1217,6 @@ enum encoding ParseEncoding(const char* encoding,
|
||||
return BUFFER;
|
||||
} else if (strcasecmp(encoding, "hex") == 0) {
|
||||
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 {
|
||||
return default_encoding;
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ var assert = require('assert');
|
||||
var Buffer = require('buffer').Buffer;
|
||||
|
||||
// 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({}, 'raws'), 15);
|
||||
assert.equal(Buffer.byteLength({}, 'binary'), 15);
|
||||
assert.equal(Buffer.byteLength(), 9);
|
||||
|
||||
// special case: zero length string
|
||||
|
@ -6,7 +6,7 @@ var fs = require('fs');
|
||||
var got_error = false;
|
||||
|
||||
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) {
|
||||
got_error = true;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user