src: use UTF-8 for naming interfaces in unix
Use a UTF-8 encoded string for naming interfaces in unix, instead of using Latin-1, as had been done on windows previously. PR-URL: https://github.com/nodejs/node/pull/21926 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
86cae946de
commit
07cb69720b
@ -257,15 +257,13 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
|
|||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
const char* const raw_name = interfaces[i].name;
|
const char* const raw_name = interfaces[i].name;
|
||||||
|
|
||||||
// On Windows, the interface name is the UTF8-encoded friendly name and may
|
// Use UTF-8 on both Windows and Unixes (While it may be true that UNIX
|
||||||
// contain non-ASCII characters. On UNIX, it's just a binary string with
|
// systems are somewhat encoding-agnostic here, it’s more than reasonable
|
||||||
// no particular encoding but we treat it as a one-byte Latin-1 string.
|
// to assume UTF8 as the default as well. It’s what people will expect if
|
||||||
#ifdef _WIN32
|
// they name the interface from any input that uses UTF-8, which should be
|
||||||
|
// the most frequent case by far these days.)
|
||||||
name = String::NewFromUtf8(env->isolate(), raw_name,
|
name = String::NewFromUtf8(env->isolate(), raw_name,
|
||||||
v8::NewStringType::kNormal).ToLocalChecked();
|
v8::NewStringType::kNormal).ToLocalChecked();
|
||||||
#else
|
|
||||||
name = OneByteString(env->isolate(), raw_name);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret->Has(env->context(), name).FromJust()) {
|
if (ret->Has(env->context(), name).FromJust()) {
|
||||||
ifarr = Local<Array>::Cast(ret->Get(name));
|
ifarr = Local<Array>::Cast(ret->Get(name));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user