Skip to content

[Replacement]: is-utf8 #1024

Closed
Closed

Description

@outslept

Package to replace

is-utf8

Suggested replacement(s)

const decoder = new TextDecoder('utf-8', { fatal: true });

const isUtf8 = (bytes) => {
  try {
    decoder.decode(bytes);
    return true;
  } catch {
    return false;
  }
};

Manifest type

micro-utility (tiny utility replaceable with native code or removal)

Rationale

inlinable. this variation is even better than the og

Availability

No response

Code example (optional)

Activity

  1. dreyfus92 commented on Aug 27, 2026

    @dreyfus92
    Member

    i'd rather go with the native API here than the TextDecoder variant. node has a native buffer.isUtf8() since 18.14 (import { isUtf8 } from 'node:buffer')

    wdyt @43081j ?

  2. gameroman commented on Aug 27, 2026

    @gameroman
    Contributor

    buffer.isUtf8() is a good choice for Node.js

    For browsers TextDecoder is the way to do it

  3. 43081j commented on Aug 29, 2026

    @43081j
    Contributor

    we need to show both i guess, so maybe use a documented replacement for this one?

  4. gameroman commented on Aug 29, 2026

    @gameroman
    Contributor

    Yeah, makes sense 👍

  5. added
    accepted
    on Aug 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions