npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@leismore/lmos-nodejs-unicode-print-chars

v1.0.0

Published

A class represents a string of printable characters in Unicode.

Downloads

214

Readme

lmos-nodejs-unicode-print-chars

A class represents a string of printable characters in Unicode.

A robust Node.js utility to validate, sanitize, and ensure strings contain only safe, printable Unicode characters.

Motivation

In text processing, certain characters are invisible but active. Legacy control characters like BEL (ASCII 07) can trigger machine bells, while DEL (ASCII 7F) can alter text streams.

If an online form accepts user input and blindly processes it without validation, malicious or malformed inputs containing hidden control characters can disrupt your application, break JSON parsing, corrupt logs, or exploit text-rendering engines.

While modern frameworks offer basic protections, the safest practice is defense-in-depth: stopping unwanted characters at the very beginning of their journey.

This package provides a strict boundary for user data, ensuring that your strings consist entirely of valid, safe, and visible printable characters across the Unicode spectrum.

Installation

npm install @leismore/lmos-nodejs-unicode-print-chars

Test

npm test

Build

npm run build

Examples


import { PrintableCharsUni, PCUError } from '@leismore/lmos-nodejs-unicode-print-chars';

const STRING_VALID_EN = 'I know that I know nothing. 🏛️';
const STRING_VALID_ZH = '我唯一知道的就是我一无所知。';
const STRING_VALID_JP = '私は自分が何も知らないということだけを知っている。';

// Throws PCUError, if illegal characters
const pcuEN = new PrintableCharsUni(STRING_VALID_EN);
const pcuZH = new PrintableCharsUni(STRING_VALID_ZH);
const pcuJP = new PrintableCharsUni(STRING_VALID_JP);

/**
 * Output:
 * - I know that I know nothing. 🏛️
 * - 我唯一知道的就是我一无所知。
 * - 私は自分が何も知らないということだけを知っている。
 */

console.log(String(pcuEN));
console.log(String(pcuZH));
console.log(String(pcuJP));

API Reference

Exports

export { PCUError, PrintableCharsUni };
export type { PCUErrorErr };

PCUError

PCUError Class Properties

  • error : PCUErrorErr
  • previous? : Error
  • timestamp : Date

PCUError is the Error class for this package. All errors thrown by this library are instances of this class, allowing you to easily catch and handle them in your application.

PCUError extends the LMError class from @leismore/lmos-nodejs-lmerror. For more details, please refer to the documentation of @leismore/lmos-nodejs-lmerror.

PCUErrorErr

type PCUErrorErr = {
  readonly message: string, // Message for human. Only ASCII printable characters allowed.
  readonly code:    string  // Code for machine. Only letter, number, and underscore allowed.
};

PrintableCharsUni

class PrintableCharsUni {

    /**
     * @throws {PCUError}
     * 2    invalid_string
     */
    constructor(chars: string)

    public toString(): string

    public static isValid(chars: string): boolean

    /**
     * @throws {PCUError}
     * 3    not_string
     */
    public static removeInvalidChars(chars: string): string

}

PrintableCharsUni class represents a string of printable characters in Unicode.

License

© Leismore™ 2026

MIT License

Donation

Help us to pay our bills, so we can focus on developing and maintaining this project.

Authors

Credits

References


Product of Leismore™ OpenSource Project

Supported by Leismore™ (Australian Business Number: 25 935 862 619)