Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing all ASCII characters in Javascript

I need to do something like this:

  1. Have a variable of some type.
  2. 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?

like image 741
Amit Tomar Avatar asked Oct 09 '12 07:10

Amit Tomar


People also ask

How many ascii characters can be printable?

Related subjects: Computing hardware and infrastructure. There are 95 printable ASCII characters, numbered 32 to 126. ASCII (American Standard Code for Information Interchange), generally pronounced [ˈæski], is a character encoding based on the English alphabet.

What is ASCII JavaScript?

ASCII stands for American Standard Code for Information Interchange. ASCII is a numeric value that is given to different characters and symbols for computers to store and manipulate. For example, the ASCII value of the letter 'A' is 65. Resource: ASCII chart of all 127 characters in JavaScript.

What is ASCII value of A to Z?

The ASCII value of the lowercase alphabet is from 97 to 122. And, the ASCII value of the uppercase alphabet is from 65 to 90.


1 Answers

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.

like image 188
Michael Krelin - hacker Avatar answered Oct 03 '22 00:10

Michael Krelin - hacker