I’m screwing around with some javascript that would insert a random miscellaneous unicode symbol somewhere in a document. (like these symbols)
However, I want to make sure that I’m only inserting the generated character, if that character is not to be printed as one of those “” squares.
So far, I’m generating random numbers between 2600 and 2699. But I want to make sure they’re valid and not squares. Nevermind the fact that I’m not generating hex codes, just ints, it doesn’t really matter which symbols I’m missing.
String.fromCharCode(2600+(Math.floor(Math.random()*70)));
Calling this a few times would give me: “ਖ਼ੁੜਯ”
Cheers!
There are two fundamental things that might show as such squares (or a question mark in a lozenge, or something different entirely, e.g. the code point value in a square):
For the first case you can try throwing out invalid code points (non-characters), but for the second you have little choice in the matter, as it all depends on the font, the browser, other installed fonts, the technology used to render text, etc.