Skip to content

os.hostname() return garbled code on windows if the host name contains non ascii characters #38255

@eagleliang

Description

@eagleliang
  • 12.14.0 -- latest version:
  • Window 10:
  • Subsystem:

What steps will reproduce the bug?

  1. windows 7/8/10
  2. set pc's name to ANDREW-ü-LAPTOP
  3. make sure 'Use unicode UTF-8 support' is not enable in windows language setting
  4. in node CLI, invoke os.hostname(), it returns ANDREW-�-LAPTOP

How often does it reproduce? Is there a required condition?

Always happen.

What is the expected behavior?

ANDREW-ü-LAPTOP

What do you see instead?

ANDREW-�-LAPTOP

Additional information

the fix of #27848 would work fine on linux/macOs. But on windows, libuv's implement does not decoding the string which return be windows API, which cause this bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.libuvIssues and PRs related to the libuv dependency or the uv binding.windowsIssues and PRs related to the Windows platform.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions