buffer: introduce latin1 encoding term

When node began using the OneByte API (f150d56) it also switched to
officially supporting ISO-8859-1. Though at the time no new encoding
string was introduced.

Introduce the new encoding string 'latin1' to be more explicit. The
previous 'binary' and documented as an alias to 'latin1'.  While many
tests have switched to use 'latin1', there are still plenty that do both
'binary' and 'latin1' checks side-by-side to ensure there is no
regression.

PR-URL: https://github.com/nodejs/node/pull/7111
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Trevor Norris committed 2016-06-07 13:51:14 -06:00
1 parent c300ba2212
commit 54cc7212df
37 files changed
+246 -124

No files matched your search

+7 -7
View File
@@ -491,8 +491,8 @@ void StringSlice<UCS2>(const FunctionCallbackInfo<Value>& args) {
}
void BinarySlice(const FunctionCallbackInfo<Value>& args) {
StringSlice<BINARY>(args);
void Latin1Slice(const FunctionCallbackInfo<Value>& args) {
StringSlice<LATIN1>(args);
}
@@ -692,8 +692,8 @@ void Base64Write(const FunctionCallbackInfo<Value>& args) {
}
void BinaryWrite(const FunctionCallbackInfo<Value>& args) {
StringWrite<BINARY>(args);
void Latin1Write(const FunctionCallbackInfo<Value>& args) {
StringWrite<LATIN1>(args);
}
@@ -1035,7 +1035,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
needle_length,
offset,
is_forward);
} else if (enc == BINARY) {
} else if (enc == LATIN1) {
uint8_t* needle_data = static_cast<uint8_t*>(malloc(needle_length));
if (needle_data == nullptr) {
return args.GetReturnValue().Set(-1);
@@ -1183,14 +1183,14 @@ void SetupBufferJS(const FunctionCallbackInfo<Value>& args) {
env->SetMethod(proto, "asciiSlice", AsciiSlice);
env->SetMethod(proto, "base64Slice", Base64Slice);
env->SetMethod(proto, "binarySlice", BinarySlice);
env->SetMethod(proto, "latin1Slice", Latin1Slice);
env->SetMethod(proto, "hexSlice", HexSlice);
env->SetMethod(proto, "ucs2Slice", Ucs2Slice);
env->SetMethod(proto, "utf8Slice", Utf8Slice);
env->SetMethod(proto, "asciiWrite", AsciiWrite);
env->SetMethod(proto, "base64Write", Base64Write);
env->SetMethod(proto, "binaryWrite", BinaryWrite);
env->SetMethod(proto, "latin1Write", Latin1Write);
env->SetMethod(proto, "hexWrite", HexWrite);
env->SetMethod(proto, "ucs2Write", Ucs2Write);
env->SetMethod(proto, "utf8Write", Utf8Write);