Link to home
Start Free TrialLog in
Avatar of cophi
cophi

asked on

CFile write problem

I'm trying to write using CFile.

CFile cf(L"C:\\Text.txt", CFile::modeWrite);
cf.Write(m_values, m_values.GetLength());
cf.Close();

When I write out the file it comes out like this:

H e r e   i s   m y   e x a m p l e .

Why isn't it spaced together like normal. If you debug and see the value of m_values, its("Here is my example.").  Why does it come out all funky?
Avatar of cophi
cophi

ASKER

m_values is a CString
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The other way to go is to avoid using UNICODE.
For one thing you won't need to put L in front of all of your string constants :)

To avoid using Unicode, look in your Project settings.  In the General tab, look to the Preprocessor Definitions... there you will find the word _UNICODE.  That is what is causing the problem.  Remove it and all of your strings will be composed of "normal" 8-bit characters.

Of course, if you expect to sell a Mandarin Chinese version of your program, the UNICODE is the way to go.  Unicode text is also handy if you will be accessing a lot of COM objects.

-- Dan
>>Of course, if you expect to sell a Mandarin Chinese version of your program, the UNICODE is the
>>way to go.

No. UNICODE is the charset of the new century *g*
Avatar of cophi

ASKER

Well I do have to use UNICODE.  How do I use CFile with Unicode for writing and reading?
Avatar of cophi

ASKER

I figured it out
I was just pointing out the alternative... I've seen lost of programmers confused about issues that there is no need to ever be confused about.  If one does not need Unicode,  why use it?  It just doubles the size of every string of text and complicates things that are otherwise very simple. :-)