Converts html strings into unicode strings that use special unicode characters to simulate rich text.
It turns Hello, <b>world</b>!
into Hello, ๐๐ผ๐ฟ๐น๐ฑ!
.
You can try this library online.
html | html2unicode(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โฝโฟโบยนโพ |
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 "๐๐ฒ๐น๐น๐ผ, ๐ฌ๐ค๐ง๐ก๐!";
var html2unicode = require("html2unicode");
var htmlStr = "<b>Hello, <i>world</i></b>!";
html2unicode
.html2unicode(htmlStr)
.then(function(str) {
console.log(str);
// This will display "๐๐ฒ๐น๐น๐ผ, ๐ฌ๐ค๐ง๐ก๐!";
});
This package offers a command-line interface.
$ npx html2unicode '<b>bold</b>'
๐ฏ๐ผ๐น๐ฑ