Socket
Book a DemoInstallSign in
Socket

@alexbosworth/html2unicode

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alexbosworth/html2unicode

Convert HTML to unicode strings.

1.1.5
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

html2unicode

Converts html strings into unicode strings that use special unicode characters to simulate rich text.

It turns Hello, <b>world</b>! into Hello, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!.

Try it from your browser

You can try this library online.

Examples

htmlhtml2unicode(html)
<b>Hello</b>๐—›๐—ฒ๐—น๐—น๐—ผ
<strong>Hello, world!</strong>๐—›๐—ฒ๐—น๐—น๐—ผ, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!
<em>hello</em>๐˜ฉ๐˜ฆ๐˜ญ๐˜ญ๐˜ฐ
normal <i>italics <b>bolditalics</b></i>normal ๐˜ช๐˜ต๐˜ข๐˜ญ๐˜ช๐˜ค๐˜ด ๐™—๐™ค๐™ก๐™™๐™ž๐™ฉ๐™–๐™ก๐™ž๐™˜๐™จ
<i><b>0123456789</b></i>๐Ÿฌ๐Ÿญ๐Ÿฎ๐Ÿฏ๐Ÿฐ๐Ÿฑ๐Ÿฒ๐Ÿณ๐Ÿด๐Ÿต
<pre>Hello, world!</pre>๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!
<code>Hello, world!</code>๐™ท๐šŽ๐š•๐š•๐š˜, ๐š ๐š˜๐š›๐š•๐š!
<code>Hello, <b>world</b>!</code>๐™ท๐šŽ๐š•๐š•๐š˜, ๐˜„๐—ผ๐—ฟ๐—น๐—ฑ!
<samp>007</samp>๐Ÿถ๐Ÿถ๐Ÿฝ
<var>hello</var>๐“ฑ๐“ฎ๐“ต๐“ต๐“ธ
x<sub>2</sub>xโ‚‚
x<sup>(n+1)</sup>xโฝโฟโบยนโพ

API

See the full documentation.

Using ES6

const html2unicode = require("html2unicode");

async function test() {
	const htmlStr = "<b>Hello, <i>world</i></b>!";
	const result = await html2unicode.html2unicode(htmlStr);
	console.log(result);
}

test() // This will display "๐—›๐—ฒ๐—น๐—น๐—ผ, ๐™ฌ๐™ค๐™ง๐™ก๐™™!";

Using old-style promise chaining

var html2unicode = require("html2unicode");

var htmlStr = "<b>Hello, <i>world</i></b>!";

html2unicode
	.html2unicode(htmlStr)
	.then(function(str) {
		console.log(str);
		// This will display "๐—›๐—ฒ๐—น๐—น๐—ผ, ๐™ฌ๐™ค๐™ง๐™ก๐™™!";
	});

CLI

This package offers a command-line interface.

$ npx html2unicode '<b>bold</b>'
๐—ฏ๐—ผ๐—น๐—ฑ

Keywords

html

FAQs

Package last updated on 18 Jul 2020

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.