Skip to content

Should aliased encodings be dropped? #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JordanMartinez opened this issue Jul 5, 2023 · 0 comments
Open

Should aliased encodings be dropped? #58

JordanMartinez opened this issue Jul 5, 2023 · 0 comments

Comments

@JordanMartinez
Copy link
Contributor

As of Node 18, there are 3 encodings that are simply aliases to another:

  • binary is an alias for latin1
    • See binary strings for more background on this topic. The name of this encoding can be very misleading, as all of the encodings listed here convert between strings and binary data. For converting between strings and Buffers, typically 'utf8' is the right choice.

  • ucs2 and ucs-2 are both aliases to utf16le.
  • ascii is an alias in one direction but not another:
    • For 7-bit ASCII data only. When encoding a string into a Buffer, this is equivalent to using 'latin1'. When decoding a Buffer into a string, using this encoding will additionally unset the highest bit of each byte before decoding as 'latin1'. Generally, there should be no reason to use this encoding, as 'utf8' (or, if the data is known to always be ASCII-only, 'latin1') will be a better choice when encoding or decoding ASCII-only text. It is only provided for legacy compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant