Boost logo

Boost Users :

From: DY, JERRY U (SBCSI) (jd2419_at_[hidden])
Date: 2004-04-30 14:06:01

I'm converting our code to use lexical_cast for converting between our
numeric types to string. It worked mostly but was surprised to see what
looked like graphic characters on my screen. It turns out that when we
wanted to display the ascii value of a character, lexical_cast<string>
doesn't work -- it doesn't treat the char as a numeric, which when we
really think about it, makes a lot of sense. Casting the char to int
solves the problem. But I was just wondering how the experts would
handle this.

char c = 65;
string s1 = lexical_cast<string>(c) // s1 = "A"
string s2 = lexical_cast<string>((int)c) // s2 = "65"



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at