Most of your content comes form _bstr_t strings, which are encoded as "UTF-16LE". Since the majority is already in a Unicode encoding, it's best to keep it in a Unicode encoding so that nothing is lost due to Unicode<->Codepage conversions.

I would recommend using encoding="UTF-8" in your XML template. If your template doesn't have special characters in it, then that's all you'll need to do to the template.

The next step is converting your _bstr_t strings to UTF8 before writing it to the file. You can use the code in this thread to do that: http://forums.codeguru.com/showthrea...82#post1877082
The usage would be something like this:
Code:
_bstr_t bstr;
std::string utf8str = wstr_to_str((const whcar_t*)bstr, CP_UTF8);
const char *raw = utf8str.c_str();
gg