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?
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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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*
>>way to go.
No. UNICODE is the charset of the new century *g*
ASKER
Well I do have to use UNICODE. How do I use CFile with Unicode for writing and reading?
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. :-)
ASKER