PDA

View Full Version : [Homework] Need some help on ASCII table... -.-



ShowerThoughts
11-11-2009, 07:17 PM
I need help on this.
I checked like 2 ASCII tables and I need these codes.


Decimal Binary Hex ASCII
65 1000001 41h A
97 1100001 61h a
!
?
191 0xBF ¿
ß

I feel very stupid, I probably am, I remember that hex was like numeric but could also have Alphanumeric characters, to count but why 41h is Hex and 0xBF is Hex?

I need help on this, thank you! :)

[-jesus-]
11-13-2009, 06:56 AM
Decimal Binary Hex ASCII
63 00111111 3F ?
191 10111111 BF ¿
33 00100001 21 !
223 11011111 DF ß

Use the program I've attached for converting.

Zyt3x
11-13-2009, 08:09 AM
Hex = 0 1 2 3 4 5 6 7 8 9 A B C D E F
I present you my Hex Workshop LITE:

//HTS = HexToStr
function HTS(Hex : String): String;
var
I, X, L, H : Integer;
sArr, hArr : TStringArray;
begin
sArr := [' ', '!', '"', '#', '$', '%', '&', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'];
hArr := ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4A', '4B', '4C', '4D', '4E', '4F', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5A', '5B', '5C', '5D', '5E', '5F', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6A', '6B', '6C', '6D', '6E', '6F', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7A', '7B', '7C', '7D', '7E'];
L := Length(Hex);
H := High(hArr);
for I := 0 to L do
if I mod 2 <> 0 then
for X := 0 to H do
if Hex[I] + Hex[I+1] = hArr[X] then
Result := Result + sArr[X];
end;

//STH = StrToHex
function STH(Str : String): String;
var
I, X, L, ArrH : Integer;
sArr, hArr : array of String;
begin
sArr := [' ', '!', '"', '#', '$', '%', '&', '''', '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'];
hArr := ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2A', '2B', '2C', '2D', '2E', '2F', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3A', '3B', '3C', '3D', '3E', '3F', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4A', '4B', '4C', '4D', '4E', '4F', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5A', '5B', '5C', '5D', '5E', '5F', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6A', '6B', '6C', '6D', '6E', '6F', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7A', '7B', '7C', '7D', '7E'];
L := Length(Str);
ArrH := High(sArr);
for I := 1 to L do
for X := 0 to ArrH do
if Str[I] = sArr[X] then
Result := Result + hArr[X];
end;

begin
ClearDebug;
WriteLn(HTS('48656C6C6F'));
end.(the heavy version has some binary in it too :P)

HexToBinary:
0 = 0000
1 = 0001
2 = 0010
3 = 0011
4 = 0100
5 = 0101
6 = 0110
7 = 0111
8 = 1000
9 = 1001
A = 1010
B = 1011
C = 1100
D = 1101
E = 1110
F = 1111