summaryrefslogtreecommitdiff
path: root/src/node_os.cc
diff options
context:
space:
mode:
authorUjjwal Sharma <usharma1998@gmail.com>2018-07-22 03:36:20 +0530
committerAnna Henningsen <anna@addaleax.net>2018-07-29 17:04:48 +0200
commit07cb69720bec251a1c450b3770db2136ac009778 (patch)
tree39e1b74be2ed9de5812ac5afe74a5e1c95596b2f /src/node_os.cc
parent86cae946defaf4a3976edfd449ff226681dbd34e (diff)
downloadandroid-node-v8-07cb69720bec251a1c450b3770db2136ac009778.tar.gz
android-node-v8-07cb69720bec251a1c450b3770db2136ac009778.tar.bz2
android-node-v8-07cb69720bec251a1c450b3770db2136ac009778.zip
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>
Diffstat (limited to 'src/node_os.cc')
-rw-r--r--src/node_os.cc12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/node_os.cc b/src/node_os.cc
index e0ea7e7b82..c9eef808b0 100644
--- a/src/node_os.cc
+++ b/src/node_os.cc
@@ -257,15 +257,13 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) {
for (i = 0; i < count; i++) {
const char* const raw_name = interfaces[i].name;
- // On Windows, the interface name is the UTF8-encoded friendly name and may
- // contain non-ASCII characters. On UNIX, it's just a binary string with
- // no particular encoding but we treat it as a one-byte Latin-1 string.
-#ifdef _WIN32
+ // Use UTF-8 on both Windows and Unixes (While it may be true that UNIX
+ // systems are somewhat encoding-agnostic here, it’s more than reasonable
+ // to assume UTF8 as the default as well. It’s what people will expect if
+ // 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,
v8::NewStringType::kNormal).ToLocalChecked();
-#else
- name = OneByteString(env->isolate(), raw_name);
-#endif
if (ret->Has(env->context(), name).FromJust()) {
ifarr = Local<Array>::Cast(ret->Get(name));