purescript-node/purescript-node-buffer

Should aliased encodings be dropped?

Opened this issue · 0 comments

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.