Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check special character support with javascript?

How can I check if a special character is available in the user's computer?

For example: ♥ ♦ ♣ ♠ ♪ ♫ ¶

If the user's browser doesn't support one of them, then a rectangle (󴈿) will appear instead of the symbol.

like image 936
Danny Fox Avatar asked Mar 15 '26 03:03

Danny Fox


1 Answers

I’m afraid there’s no way to test it, and there’s the added complexity that even if a character is available, browsers (especially IE) may fail to render it.

On the other hand, the information would not be particularly useful, except perhaps in the sense that you could dynamically change the character to an image if it can’t be rendered as a character.

A better approach to having your characters rendered properly is to write your style sheets so that they select suitable fonts. This also addresses the problem that a character might be displayed using a font that does not suit the overall design, such as the basic copytext font.

For example, if you need the characters ♥ ♦ ♣ ♠ ♪ ♫ ¶, select a font that contains them and all the other characters you need. This would probably boil down just to

body { font-family: Arial, sans-serif; }
like image 79
Jukka K. Korpela Avatar answered Mar 17 '26 16:03

Jukka K. Korpela



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!