Disclaimer
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.
Background
The 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 ReadString
and WriteString
functions in order to do some conversion. It also provides the functions ReadBOM
and WriteBOM
to handle an optional bute order mark in the file.
If _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 CStdioFile
.
History
- 9-Jul-2004
Initial version.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.