A
Angus
int day;
std::string strDate = _T("01013000");
std::string strPart = strDate.substr(0, 2);
std::istringstream strm(strPart);
strm >> day;
// Great, day = 1
But...
int day;
std::wstring strDate = _T("01013000");
std::wstring strPart = strDate.substr(0, 2);
std::wistringstream strm(strPart);
strm >> day;
// Bad, day = 48
48 is ascii code for a zero. But why don't I het same behaviour as
for non-Unicode?
Same effect for the month and year. For the year I get 51 - ascii
code for 3.
What am I doing wrong?
In addition, another question on stringstream. If I use strm to get
the day then how do I clear strm to then get the month. I tried
strm.str(_T("")) and strm.clear - but neither worked in clearing
properly. So I was not able to get month.
std::string strDate = _T("01013000");
std::string strPart = strDate.substr(0, 2);
std::istringstream strm(strPart);
strm >> day;
// Great, day = 1
But...
int day;
std::wstring strDate = _T("01013000");
std::wstring strPart = strDate.substr(0, 2);
std::wistringstream strm(strPart);
strm >> day;
// Bad, day = 48
48 is ascii code for a zero. But why don't I het same behaviour as
for non-Unicode?
Same effect for the month and year. For the year I get 51 - ascii
code for 3.
What am I doing wrong?
In addition, another question on stringstream. If I use strm to get
the day then how do I clear strm to then get the month. I tried
strm.str(_T("")) and strm.clear - but neither worked in clearing
properly. So I was not able to get month.