hi all ,...
iam making a simple disk editor , and i need a methode that
convert from ascii to Hex representation
thank u all

## All 2 Replies

hi all ,...
iam making a simple disk editor , and i need a methode that
convert from ascii to Hex representation
thank u all

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 (\$30) thru 57 (\$39).

If you want lower case, then 'a' thru 'f' are 97 (\$61) thru 102 (\$66).

If you want upper, then 'A' thru 'F' are 65 (\$41) thru 70 (\$46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 (\$30) to it, then check to see if it is larger than 57 (\$39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

hi Nathan..
thank u for ur kind replay , and although i figured it out and completed my disk editor program , i want to thank u for ur interest.
and i hope we can meet agian in other arguments.
thank u
abee

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 (\$30) thru 57 (\$39).

If you want lower case, then 'a' thru 'f' are 97 (\$61) thru 102 (\$66).

If you want upper, then 'A' thru 'F' are 65 (\$41) thru 70 (\$46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 (\$30) to it, then check to see if it is larger than 57 (\$39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.