I know an ASCII character takes 8 bits but how do you print a character on screen with those bits?

link|improve this question
What operating system? Where? command line? programming language? – Mikel Jan 24 '11 at 21:44
1  
ASCII actually only takes 7 bits. – Ignacio Vazquez-Abrams Jan 24 '11 at 21:44
I really meant how a character is represented on screen. How does 7 bits make up a 'character print'. – user32344 Jan 24 '11 at 21:46
feedback

4 Answers

up vote 3 down vote accepted

The byte is used as a lookup in a font table, and the appropriate pixels are lit for that character at the appropriate position.

link|improve this answer
What could be the maximum number of pixels allowed for character? – user32344 Jan 24 '11 at 21:47
not only "the byte" but also (in unicode environments) any other glyph. you take the 'code', search for the visual representative in a lookup table and then you render it. ignacios answers is the correct one. – akira Jan 24 '11 at 21:48
@user32344: you can lookup a glyph in a vector font ... so you can render it with as much pixels as you like. – akira Jan 24 '11 at 21:49
It is completely dependent on the mechanism used for displaying the pixels on-screen, but a 8×16 cell is usually more than enough for PC text mode. – Ignacio Vazquez-Abrams Jan 24 '11 at 21:49
1  
@user32355 Most fonts these days are represented by vector information. That way there is virtually no maximum size limit to the font. – BloodPhilia Jan 24 '11 at 21:50
show 1 more comment
feedback

You mean rather than doing

echo a

You want to type

echo 00111101

or something?

I think you'd have to convert it from binary to octal first. Then you can do:

echo -e "\0141"
link|improve this answer
feedback
$ printbin () { printf "\\$((2#$1/64*100+2#$1%64*10+2#$1%8))\n"; }
$ printbin 1000001
A
$ printbin 1100001
a
link|improve this answer
feedback

In Windows, you can use a character's Alt character code to print it by pressing Alt + [code] on the Numpad. In some cases, the Alt character code coincides with its Unicode character code.

Example: Alt + 250 = รบ

You can find the whole list of Alt codes by running the Character Map applications (charmap.exe).

link|improve this answer
1  
-1: The code isn't Unicode. It's the Windows Alt Key code – Wuffers Jan 24 '11 at 22:18
You're right. However, many Alt Key codes coincide with the character's Unicode character code. Sorry for the confusion. – Juliana Peña Jan 25 '11 at 2:23
yep.. the ascii codes do overlap unicode. it's also possible to type unicode(in hex) from the numpad, but entering unicode like that may be dependent on application +1 to cancel the downvote of -1! – barlop Jan 30 '11 at 12:45
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.