Converting hex into ascii

  • Thread starter Thread starter Randy
  • Start date Start date
Randy said:
Hello,

I'd like to know how to convert a code in hex into a code ascii.

This question doesn't make much sense.
(Hexadecimal is a way to express numbers
while ASCII is a std defining which glyphs
are represented by which numbers.)
I assume you have a string representation
of a hexadecimal number and need the number
in a char. One way to do this is this:

char hex2char(const std::string& str)
{
std::istringstream iss(str);
char ch;
iss >> ch;
if( !iss ) {
throw conversion_error(str);
}
return ch;
}

HTH!

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
Back
Top