Javascript function to convert a string into different kind of โคโโโโโโ variants.
<script src="path/to/toUnicodeVariant.js"></script>const toUnicodeVariant = require('path/to/toUnicodeVariant.js') toUnicodeVariant(string, variant, flags)
...
toUnicodeVariant('monospace', 'm') //like first row below | Variant | Alias | Description | Example |
|---|---|---|---|
| monospace | m | Monospace | ๐๐๐๐๐๐๐๐๐ |
| bold | b | Bold text | ๐๐จ๐ฅ๐ |
| italic | i | Italic text | ๐๐ก๐๐๐๐ |
| bold italic | bi | bold+italic text | ๐๐๐๐ ๐๐๐๐๐๐ |
| script | c | Handwriting style | ๐๐ธ๐๐พ๐ ๐ |
| bold script | bc | Bolder handwriting | ๐ซ๐ธ๐ต๐ญ ๐ผ๐ฌ๐ป๐ฒ๐น๐ฝ |
| gothic | g | Gothic (fraktur) | ๐ค๐ฌ๐ฑ๐ฅ๐ฆ๐ |
| gothic bold | gb | Gothic in bold | ๐๐๐๐๐๐ ๐๐๐๐ |
| doublestruck | d | Outlined text | ๐๐ ๐ฆ๐๐๐๐ค๐ฅ๐ฃ๐ฆ๐๐ |
| ๐๐บ๐๐ | s | Sans-serif style | ๐๐บ๐๐ |
| bold ๐๐บ๐๐ | bs | Bold sans-serif | ๐ฏ๐ผ๐น๐ฑ ๐๐ฎ๐ป๐ |
| italic ๐๐บ๐๐ | is | Italic sans-serif | ๐ช๐ต๐ข๐ญ๐ช๐ค ๐ด๐ข๐ฏ๐ด |
| bold italic sans | bis | Bold italic sans-serif | ๐๐ค๐ก๐ ๐๐ฉ๐๐ก๐๐ ๐จ๐๐ฃ๐จ |
| circled | o | Letters within circles | โโโกโโโโ |
| circled negative | on | -- negative | ๐ ๐ ๐ ก๐ ๐ ๐ ๐ |
| squared | q | Letters within squares | ๐ ๐ ๐ ๐ฐ๐ ๐ด๐ณ |
| squared negative | qn | -- negative | ๐๐๐๐ ฐ๐๐ ด๐ ณ |
| paranthesis | p | Letters within paranthesis | โซโโญโ โฉโฏโฃโ โฎโค |
| fullwidth | w | Wider monospace font | ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ๏ฝ |
Besides that, the text can be enriched with underline or strike (or both) through the flags param :
toUnicodeVariant('gothic', 'g', 'underline')| Variant | Flags | Example |
|---|---|---|
| gothic | underline | ๐คฬฒ๐ฌฬฒ๐ฑฬฒ๐ฅฬฒ๐ฆฬฒ๐ ฬฒ |
| doublestruck | strike | ๐ธฬถ๐นฬถโฬถ๐ปฬถ๐ผฬถ๐ฝฬถ๐พฬถโฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ |
| sans | u,s | ๐ขฬฒฬถ๐ฃฬฒฬถ๐คฬฒฬถ๐ฅฬฒฬถ๐ฆฬฒฬถ๐งฬฒฬถ๐จฬฒฬถ๐ฉฬฒฬถ |
Browser: test/browser.html
Node: test$ node node.js
Those tests show all variants and their coverage a-Z, along with flags. For reference, in Chrome (Ubuntu, 100.0.4896) variants looks like this :

There are really difference between browsers/readers, versions and support of unicode variants. I have not figured it all out yet. Still "script" is a really headache. Best browser for supporting both variants and flags are defently Firefox.
Originally created to show some "cool" styled text in the browsers built-in alert(), prompt() and confirm() dialogs. To show some underlined text in a standard alert() box :
alert('Really need to alert some '+toUnicodeVariant('underlined', 'bold sans', 'underline')+' text');Would look like this in a browser (here Chrome on older Ubuntu 16.04) :
Note: Most browsers have stopped supporting unicode in their native dialogs!
- There is no support for special chars such as
&,%and so on (yet, could be implemented where unicode support it) - Not all combinations of variants and flags is guaranteed to work. It is try and error.
- Some variants does not support numbers (or I have missed them) some variants does not support capital or small letters (fixed for some)
Raise an issue if you discover major flaws (or minor flaws as well). You are also more than welcome to suggest other cool unicode variants this function could support.
This work was triggered by the dare need of underlined text in browser dialogs. The Stack Overflow question https://stackoverflow.com/questions/17470817/format-the-text-in-javascript-alert-box pointed me to the right direction, even though none of the answers were actual useable.
