var username = "David Perry" + "/u4589";
I was going to start at /u0000 and go up to /uffff and see which codes break my website when outputting them :)
I know there are different functions in JS but I can't seem to figure out why I can't build a string of unicode characters. lol.
If it's too complicated don't worry about it. It's just something I wanted to tinker with.
"\u4589" instead of
>>> "/u4589" "/u4589" >>> "\u4589" "䖉"
the forward slash (
/) is just a forward slash in a string, however the backslash (
\) is an escape character.
If you wish to generate random characters or loop through a range of characters, then you could use
String.fromCharCode(), which gives you the character with the Unicode number passed as argument, e.g.
i is a variable with an integer value.
\uxxxx notation and the
String.fromCharCode() work up to 0xFFFF only, i.e. for Basic Multilingual Plane characters. This may well suffice, but if you need non-BMP characters, check out e.g. the MDN page on fromCharCode.