Skip to content

src: add node:encoding module

This is a proposal, and depends on my previous pull request

In summary, node:encoding enables unicode validation and transcoding (if needed). We can also go with a node:unicode name if users are confused with naming.

At the moment, I only added the following methods:

const encoding = require('node:encoding')

encoding.validateAscii(input: Buffer | Uint8Array | string): boolean
encoding.validateUtf8(input: Buffer | Uint8Array): boolean 
encoding.countUtf8(input: Buffer | Uint8Array)

TODO:

  • Add fast API
  • Add benchmarks
  • Add countUtf8ByteLength() and replace internal usage of node_buffer.cc byteLengthUtf8
  • Add normalize() for normalizing encodings

Merge request reports

Loading