New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@libn/utf

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libn/utf

Process UTF-8 and UTF-16.

latest
Source
npmnpm
Version
0.4.3
Version published
Maintainers
1
Created
Source

@libn/utf

Process UTF-8 and UTF-16.

default

Escape strings before including them in HTML or regex.

import { unhtml, unrexp } from "@libn/utf";
import { assertMatch } from "@std/assert";

assertMatch(unhtml("<script>alert(1)</script>"), /^[^<>]*$/);
assertMatch("(?:[\n])", RegExp(unrexp("(?:[\n])")));

Restrict strings to RFC 9839 Unicode Assignables subset, or at least replace lone surrogates.

import { uncode, unlone } from "@libn/utf";
import { assertEquals } from "@std/assert";

const string = "\ud800\0";
assertEquals(uncode(string), "\ufffd\ufffd");
assertEquals(unlone(string), "\ufffd\0");

Remove nonstandard breaks and diacritics.

import { unline, unmark } from "@libn/utf";
import { assertEquals } from "@std/assert";

const string = "\r\n\xf1";
assertEquals(unline(string), "\n\xf1");
assertEquals(unmark(string), "\r\nn");

Case fold strings to compare them case-insensitively.

import { uncase } from "@libn/utf";
import { assertEquals, assertNotEquals } from "@std/assert";

const one = "FUSS", two = "Fu\xdf";
assertNotEquals(one, two);
assertEquals(uncase(one), uncase(two));

FAQs

Package last updated on 23 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts