Skip to content

Commit 5f6579d

Browse files
committed
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: #2829 PR-URL: #2859 Reviewed-By: Brian White <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 9aa6a43 commit 5f6579d

File tree

4 files changed

+3
-19
lines changed

4 files changed

+3
-19
lines changed

lib/buffer.js

-4
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ Buffer.isEncoding = function(encoding) {
194194
case 'ucs-2':
195195
case 'utf16le':
196196
case 'utf-16le':
197-
case 'raw':
198197
return true;
199198

200199
default:
@@ -260,9 +259,6 @@ function byteLength(string, encoding) {
260259
switch (encoding) {
261260
case 'ascii':
262261
case 'binary':
263-
// Deprecated
264-
case 'raw':
265-
case 'raws':
266262
return len;
267263

268264
case 'utf8':

src/node.cc

-12
Original file line numberDiff line numberDiff line change
@@ -1217,18 +1217,6 @@ enum encoding ParseEncoding(const char* encoding,
12171217
return BUFFER;
12181218
} else if (strcasecmp(encoding, "hex") == 0) {
12191219
return HEX;
1220-
} else if (strcasecmp(encoding, "raw") == 0) {
1221-
if (!no_deprecation) {
1222-
fprintf(stderr, "'raw' (array of integers) has been removed. "
1223-
"Use 'binary'.\n");
1224-
}
1225-
return BINARY;
1226-
} else if (strcasecmp(encoding, "raws") == 0) {
1227-
if (!no_deprecation) {
1228-
fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
1229-
"Please update your code.\n");
1230-
}
1231-
return BINARY;
12321220
} else {
12331221
return default_encoding;
12341222
}

test/parallel/test-buffer-bytelength.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ var assert = require('assert');
55
var Buffer = require('buffer').Buffer;
66

77
// coerce values to string
8-
assert.equal(Buffer.byteLength(32, 'raw'), 2);
8+
assert.equal(Buffer.byteLength(32, 'binary'), 2);
99
assert.equal(Buffer.byteLength(NaN, 'utf8'), 3);
10-
assert.equal(Buffer.byteLength({}, 'raws'), 15);
10+
assert.equal(Buffer.byteLength({}, 'binary'), 15);
1111
assert.equal(Buffer.byteLength(), 9);
1212

1313
// special case: zero length string

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var fs = require('fs');
66
var got_error = false;
77

88
var filename = path.join(common.fixturesDir, 'does_not_exist.txt');
9-
fs.readFile(filename, 'raw', function(err, content) {
9+
fs.readFile(filename, 'binary', function(err, content) {
1010
if (err) {
1111
got_error = true;
1212
} else {

0 commit comments

Comments
 (0)