CStringT::AnsiToOem 

Converts all the characters in this CStringT object from the ANSI character set to the OEM character set.


void AnsiToOem();

The function is not available if _UNICODE is defined.

// OEM character 252 on most IBM-compatible computers in
// Western countries/regions is superscript n, as in 2^n.
// Converting it to the ANSI English charset results in a
// normal character 'n', which is the closest possible
// representation.
//typedef CStringT< TCHAR, StrTraitATL< TCHAR > > CAtlString;

CAtlString str((TCHAR)252);
str.OemToAnsi();
_ASSERT(str[0] == 'n');

// Be aware that in OEM to ANSI conversion the 'n'
// from the previous result cannot be converted back to
// a supsercript n because the system does not know what
// the character's value truly was.
str.AnsiToOem();
_ASSERT(str[0] != 252);
_ASSERT(str[0] == 'n');

Community Additions

ADD
Show: