This will certainly look like a very thin article, but it's all in the source
I have looked around quite a bit, both here at Code Project and elsewhere, since I thought that there must be someone who has posted such a class already. Well, I couldn't find any, so here is my own quick hack to solve the problem.
CStdioFile_UTF8 class was initially done as a step towards making Dan Goodson's excellent TodoList program support Unicode. I'm posting it here in case someone else finds it useful.
Using the code
Use the class as a plug in replacement for MFC
CStdioFile. The class overrides the
WriteString functions in order to do some conversion. It also provides the functions
WriteBOM to handle an optional bute order mark in the file.
_UNICODE is defined, the UTF16 strings used internally are converted from/to UTF8 as used in the file. If the symbol is not defined, the class acts exactly like the parent class