Click here to Skip to main content
15,912,897 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Strings revisited Pin
PaulowniaK11-Mar-10 22:19
PaulowniaK11-Mar-10 22:19 
GeneralRe: Strings revisited Pin
KarstenK11-Mar-10 22:21
mveKarstenK11-Mar-10 22:21 
GeneralRe: Strings revisited Pin
PaulowniaK14-Mar-10 15:04
PaulowniaK14-Mar-10 15:04 
GeneralRe: Strings revisited Pin
KarstenK14-Mar-10 21:34
mveKarstenK14-Mar-10 21:34 
AnswerRe: Strings revisited Pin
mahendra.kumar.78611-Mar-10 23:41
mahendra.kumar.78611-Mar-10 23:41 
GeneralRe: Strings revisited Pin
mahendra.kumar.78611-Mar-10 23:54
mahendra.kumar.78611-Mar-10 23:54 
GeneralRe: Strings revisited Pin
PaulowniaK14-Mar-10 15:03
PaulowniaK14-Mar-10 15:03 
GeneralRe: Strings revisited Pin
mahendra.kumar.78614-Mar-10 19:13
mahendra.kumar.78614-Mar-10 19:13 
The below works if u_MyFile.txt is UNICODE and the project configuration is also UNICODE.
When switching project configuration it is better to use the portable type TCHAR.

	CFile myFile(_T("C:\\u_MyFile.txt"), CFile::modeRead);
	int len = myFile.GetLength();
	const int MB_BUFFER_SIZE = 1024;
	TCHAR* pchContents = new TCHAR[len + 1];
	memset(pchContents, 0, (len + 1) * sizeof(TCHAR));
	int n = myFile.Read(pchContents, len);
    char            mbString[MB_BUFFER_SIZE];
    size_t          countConverted;
    mbstate_t       mbstate;
#ifdef _UNICODE
	pchContents++;
    ::memset((void*)&mbstate, 0, sizeof(mbstate));
    countConverted = wcsrtombs(mbString, (const wchar_t **)&pchContents, MB_BUFFER_SIZE, &mbstate); 
	CStringA myString = mbString;
    if (errno == EILSEQ)
    {
        printf( "An encoding error was detected in the string.\n" );
    }
    else 
    {
        printf( "%s\n", myString.GetBuffer());
    }
#else  /* assuming txt file read is not UNICODE */
	CString myString = pchContents;
	printf( "%s.\n", myString.GetBuffer());
#endif

QuestionTransparent background and colored text for radio button Pin
kiranin11-Mar-10 17:37
kiranin11-Mar-10 17:37 
AnswerRe: Transparent background and colored text for radio button Pin
Naveen11-Mar-10 18:09
Naveen11-Mar-10 18:09 
AnswerRe: Transparent background and colored text for radio button Pin
Mohan Ramachandra11-Mar-10 18:14
Mohan Ramachandra11-Mar-10 18:14 
AnswerRe: Transparent background and colored text for radio button Pin
Paresh Chitte11-Mar-10 18:18
Paresh Chitte11-Mar-10 18:18 
AnswerRe: Transparent background and colored text for radio button Pin
Mohan Ramachandra11-Mar-10 18:48
Mohan Ramachandra11-Mar-10 18:48 
AnswerRe: Transparent background and colored text for radio button Pin
KarstenK11-Mar-10 21:54
mveKarstenK11-Mar-10 21:54 
QuestionHow can send SMS in PDU mode by using AT commands? Pin
Le@rner11-Mar-10 17:27
Le@rner11-Mar-10 17:27 
QuestionColor For List View Control Column Pin
hellogany11-Mar-10 16:47
hellogany11-Mar-10 16:47 
AnswerRe: Color For List View Control Column Pin
chevu11-Mar-10 17:21
chevu11-Mar-10 17:21 
AnswerRe: Color For List View Control Column Pin
Naveen11-Mar-10 18:14
Naveen11-Mar-10 18:14 
QuestionMFC Drag drop Target line Pin
RakeshManohar11-Mar-10 16:40
RakeshManohar11-Mar-10 16:40 
AnswerRe: MFC Drag drop Target line Pin
Iain Clarke, Warrior Programmer11-Mar-10 22:06
Iain Clarke, Warrior Programmer11-Mar-10 22:06 
QuestionWhich licensing software to use. Pin
wattsupdoc11-Mar-10 16:31
wattsupdoc11-Mar-10 16:31 
AnswerRe: Which licensing software to use. Pin
wattsupdoc12-Mar-10 17:10
wattsupdoc12-Mar-10 17:10 
QuestionCreating File at startup error Pin
Zacory11-Mar-10 16:22
Zacory11-Mar-10 16:22 
AnswerRe: Creating File at startup error Pin
Stephen Hewitt11-Mar-10 16:36
Stephen Hewitt11-Mar-10 16:36 
GeneralRe: Creating File at startup error Pin
Zacory11-Mar-10 16:56
Zacory11-Mar-10 16:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.