Skip to content

Commit

Permalink
buffer: remove raw & raws encoding
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
thefourtheye committed Sep 16, 2015
1 parent 9aa6a43 commit 5f6579d
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 19 deletions.
4 changes: 0 additions & 4 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ Buffer.isEncoding = function(encoding) {
case 'ucs-2':
case 'utf16le':
case 'utf-16le':
case 'raw':
return true;

default:
Expand Down Expand Up @@ -260,9 +259,6 @@ function byteLength(string, encoding) {
switch (encoding) {
case 'ascii':
case 'binary':
// Deprecated
case 'raw':
case 'raws':
return len;

case 'utf8':
Expand Down
12 changes: 0 additions & 12 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-buffer-bytelength.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-file-read-noexist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5f6579d

Please sign in to comment.