Javascript function to convert a string into different kind of โคโโโโโโ variants. Originally created to show some "cool" styled text in the browsers built-in alert()
, prompt()
and confirm()
dialogs.
Usage: toUnicodeVariant(string, variant, flags)
Variant | Alias | Description | Example |
---|---|---|---|
monospace | m | Monospace | ๐๐๐๐๐๐๐๐๐ |
bold | b | Bold text | ๐๐จ๐ฅ๐ |
italic | if | 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 | โโโกโโโโ |
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:
Variant | Flags | Example |
---|---|---|
gothic | underline | ๐คฬฒ๐ฌฬฒ๐ฑฬฒ๐ฅฬฒ๐ฆฬฒ๐ ฬฒ |
paranthesis | strike | ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ๐ฬถ |
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 Ubuntu) :
- 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.