ASCII
ASCII, pronounced "ask-key", is the common code for microcomputer equipment.
It is a seven-bit code that was finalized by ANSI (American National Standards Institute) in 1968.
The standard ASCII character set consists of 128 decimal numbers ranging from zero through 127 assigned to letters, numbers, punctuation marks, and the most common special characters.
The Extended ASCII Character Set also consists of 128 decimal numbers and ranges from 128 through 255 representing additional special, mathematical, graphic, and foreign characters.
The standard ASCII character set is provided below.
Reading the table: the character code for F is 70 and the code for & is 38.
ASCII is a subset of the Unicode Character Set
Unicode Home Page: http://unicode.org/
Languages Supported: http://www.unicode.org/cldr/data/charts/supplemental/scripts_and_languages.html
|
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
0 |
nul |
soh | stx | etx | eot | enq | ack | bel | bs |
ht |
1 |
n1 |
vt | ff | cr | so | si | dle | dc1 | dc2 |
dc3 |
2 |
dc44 |
nak | syn | etb | cn | em | sub | esc | fs |
gs |
3 |
rs |
us | sp |
! |
" |
# |
$ |
% |
& |
' |
4 |
( |
) |
* |
+ |
, |
- |
. |
/ |
0 |
1 |
5 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
: |
; |
6 |
< |
+ |
> |
? |
@ |
A |
B |
C |
D |
E |
7 |
F |
G |
H |
I |
J |
K |
L |
M |
N |
O |
8 |
P |
Q |
R |
S |
T |
U |
V |
W |
X |
Y |
9 |
Z |
[ |
\ |
] |
^ |
_ |
' |
a |
b |
c |
10 |
d |
e |
f |
g |
h |
i |
j |
k |
l |
m |
11 |
n |
o |
p |
q |
r |
s |
t |
u |
v |
w |
12 |
x |
y |
z |
{ |
| |
} |
~ |
del |
|
System.out.println((char)(71)); will print G
System.out.println((int)('G')); will print 71
cout << char (71); will print G.
cout << int ('G') will print 71
Example
#include "stdafx.h"
#include <iostream>
using namespace std;
int main ()
{
char oldChar, newChar;
int convertedInt;
cout << "Please enter a character"<<endl;
cin >> oldChar;
cout << "The character you entered is: "<<oldChar<<endl;
convertedInt = int(oldChar);
newChar = char(convertedInt + 3);
cout << "The character shifted by 3 is: "<<newChar<<endl;
return 0;
}
Module Module1
Sub Main()
Dim convert1 As Integer = Asc("a")
Console.WriteLine(convert1) 'Prints 97
Dim convert2 As Char = Chr(97)Console.WriteLine(convert2) 'Prints a
End SubEnd Module