Binary-to-text encoding: Difference between revisions

Content deleted Content added
m Include hexadecimal values for characters and add subscript 8 for those present in octal
m reference Control character rather than C0 C1(C1 is 8 bits) add 7 bit binary representations
Line 12:
 
==Description==
The [[ASCII]] text-encoding standard uses 7 bits to encode characters. With this it is possible to encode 128 (i.e. 2<sup>7</sup>) unique values (0–127) to represent the alphabetic, numeric, and punctuation characters commonly used in [[English language|English]], plus a selection of [[C0Control and C1 control codescharacter|controlControl codescharacters]] which do not represent printable characters. For example, the capital letter '''A''' is ASCIIrepresented characterin 7 bits as 100 0111<sub>2</sub>, 0x41 (65<sub>8</sub>) , the numeral '''2''' is ASCII011 0010<sub>2</sub> 0x32 (50<sub>8</sub>), the character '''<nowiki>}</nowiki>''' is ASCII111 1101<sub>2</sub> 0x7D (125<sub>8</sub>), and the [[metacharacterControl character]] ''carriage return'RETURN''' is ASCII000 1101<sub>2</sub> 0x0D (13<sub>8</sub>). Systems based on ASCII use seven bits to represent these values digitally.
 
In contrast, most computers store data in memory organized in eight-bit [[byte]]s. Files that contain machine-executable code and non-textual data typically contain all 256 possible eight-bit byte values. Many computer programs came to rely on this distinction between seven-bit ''text'' and eight-bit ''binary'' data, and would not function properly if non-ASCII characters appeared in data that was expected to include only ASCII text. For example, if the value of the eighth bit is not preserved, the program might interpret a byte value above 127 as a flag telling it to perform some function.