Using Visual Studio 2012 & with Project properties:
- Configuration Properties: General: Project Defaults:Character Set: Not Set
- Configuration Properties: C++: Language:Treat WChar_t as Built In Type: No
I use an ofstream with following snippet of code: Note: the path "C:\data" is valid for this example
ofstream fexp;
fexp.open("c:\data\test.txt", ios::out|ios::binary|ios::app);
fexp << "writing some text to file with append in binary" << endl;
fexp.flush();
fexp.close();
If the file was not present in the directory, the file would be open, text written, etc. If the file already existed the file is not opened, not written to, etc. No exception occurred and no error code was found (in errno). While debugging internal to open() method, I found some internal open calls were trying to copy the filename string into wchar_t type and exited with an internal error of 13 (looking up MS Constants = Open Aborted).
MBCS has been deprecated so I don't want to be set to that. Only other option is Unicode which breaks half of my changes. Why can't I make use of the std io library??!!!
What is weirder still I had some of this working with second switch to no with 1st set to MBCS. The code worked though a lot of places in dealing with GUI contaniners such as CEdit, I had a lot superfluous code to convert from CString to string if I had to. If in essence the representation of CString is a const char* which is somewhat close to LPCTSTR (not quite). It "SHOULD" be somewhat "SIMPLE" to convert from CString to string. It is not because UNECESSARY complications of switches between UTF-8 and UTF-16 that I am not engaged in. I desire my char to be STRICTLY 1-BYTE.
What is the closest path through this madness? Do I go back to back to MBCS (even though deprecated) and change all the container methods from GetWindowText() to GetWindowTextA() for example or abandon the use of streams in Visual Studio, or what???
Please Advise, if you can... Any help would be appreciated. Thanks.
Maddog
ps: Please don't go to the trouble to convert me to embrace the full Wide environment in my code, when my product will not be sold in Asia or Arabia.
pps: one final note, I got into this because, I noted my initial install of Visual Studio 2012 defaulted to MBCS.