Writing both 8-bit and 16-bit data to a file

I'm writing both 8-bit and wide 16-bit data to the screen and an output file. I have no problems with writing out to the screen - for example:
cout<<8-bit data;
wcout<<16-bit data;

Similarly, I have used ofstream for 8-bit and wofstream for 16-bit, for example:
ofstream out;
wofstream wout;
out<<8-bit data;
wout<<16-bit data;

into the same output file (declared in the ofstream and wofstream constructors).

I find two problems with this method:

  1. I still get a mix of correct data and ints (from the 16-bit data)
  2. I cannot use manipulator functions such as setw and setfill with the wide 16-bit wcout and wout commands.

Has anyone experienced this problem? Is there a better way of doing this (ie writing both 8-bit and 16-bit data to one file).
Thanks
:slight_smile:

I found that you can use the WCHAR with the setfill() manipultor, hence:
wcout<<setfill<WCHAR>(' ')<<setw(42)

will compile and work fine.