Printing all ASCII characters in Javascript
19,360
I'm not sure how exactly you want to print, but this will console.log
printable ascii
for(var i=32;i<127;++i) console.log(String.fromCharCode(i));
You can document.write
then if that's your intention. And if the environment is unicode, it should work for unicode as well, I believe.
Related videos on Youtube
Author by
Amit Tomar
Generalist, with 8+ years of experience in : 3D Computer Graphics (OpenGL, WebGL, Three.JS, Blender). Also have exposure to UI (Qt-QML, Javascript), middleware (C/C++) & backend (Python-Flask)
Updated on June 25, 2022Comments
-
Amit Tomar almost 2 years
I need to do something like this:
- Have a variable of some type.
- Run in a loop and assign all the possible ASCII characters to this variable and print them, one by one.
Is something similar possible for UNICODE also?
-
Jukka K. Korpela over 11 yearsNo font contains all Unicode characters (even font technology currently prevents that). On the other hand, rendering engines may use different fonts – e.g., web browsers generally use some fallback fonts.
-
Yaroslav Bigus about 11 yearswhat about extended ascii?
-
Michael Krelin - hacker almost 9 yearsIt basically works with whatever encoding the interpreter uses. You may need to change range in the for loop, though ;-)
-
Dmytro almost 7 years
Array.from(Array(127).keys()).slice(32).map(a => String.fromCharCode(a))
in one expression to get the array of them all. With zeroTo function it gets shorter,zeroTo(127).slice(32).map(a => String.fromCharCode(a))