Skip to content

I/O incorrectly assumes a Unicode terminal #43673

Closed as not planned
Closed as not planned
@zzo38

Description

@zzo38

Version

v6.11.0

Platform

Linux zzo38computer 3.2.0-87-generic #125-Ubuntu SMP Fri Jun 19 08:25:10 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

  • Set LANG=C and a non-Unicode terminal.

  • Input non-Unicode text in the REPL, or using the readline interface (the example in the documentation is suitable to reproduce this bug).

  • Enter strings with escapes in the REPL such as "\x8A" or "\x9A".

  • (I don't know what console.table does, since I do not have that version of Node.js.)

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

If the locale and/or terminal emulator is not Unicode, e.g. set the environment variable LANG=C.

What is the expected behavior?

My suggestions are:

  • The problem with input probably cannot be fixed for the REPL. (But, for the readline function, this could be made an option.)

  • For output in the REPL, check for a non-Unicode locale and always display escaped codes in that case, like it already does for ASCII control codes. (This also improves security in the case of homoglyphs, etc; this way, you can change the locale if you are concerned about such a thing.)

  • For output using console.log, the existing behaviour is probably acceptable; if you need non-Unicode output then you can use the other functions to output instead, so probably this does not need to be fixed.

What do you see instead?

  • Input in the REPL that does not match the input that I typed (it replaces my input with a Unicode replacement character, which is then displayed incorrectly).

  • Broken output (if it contains any non-ASCII characters and is not being redirected to a file).

  • (I do not know what console.table does, since I do not have that version of Node.js)

Additional information

The locale will not always be Unicode; you should not incorrectly assume that it is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions