GeezerVison is showing github.com — src: use UTF-8 for naming interfaces in unix · nodejs/node@2548f75
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/node_os.cc +5-7Lines changed: 5 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -257,15 +257,13 @@ static void GetInterfaceAddresses(const FunctionCallbackInfo<Value>& args) { |
257 | 257 | for (i = 0; i < count; i++) { |
258 | 258 | const char* const raw_name = interfaces[i].name; |
259 | 259 |
|
260 | | - // On Windows, the interface name is the UTF8-encoded friendly name and may |
261 | | - // contain non-ASCII characters. On UNIX, it's just a binary string with |
262 | | - // no particular encoding but we treat it as a one-byte Latin-1 string. |
263 | | -#ifdef _WIN32 |
| 260 | + // Use UTF-8 on both Windows and Unixes (While it may be true that UNIX |
| 261 | + // systems are somewhat encoding-agnostic here, it’s more than reasonable |
| 262 | + // to assume UTF8 as the default as well. It’s what people will expect if |
| 263 | + // they name the interface from any input that uses UTF-8, which should be |
| 264 | + // the most frequent case by far these days.) |
264 | 265 | name = String::NewFromUtf8(env->isolate(), raw_name, |
265 | 266 | v8::NewStringType::kNormal).ToLocalChecked(); |
266 | | -#else |
267 | | - name = OneByteString(env->isolate(), raw_name); |
268 | | -#endif |
269 | 267 |
|
270 | 268 | if (ret->Has(env->context(), name).FromJust()) { |
271 | 269 | ifarr = Local<Array>::Cast(ret->Get(name)); |
|