Click here to Skip to main content
16,004,927 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: Conversion of C++ templates into C code Pin
CP Visitor29-Jun-05 4:14
CP Visitor29-Jun-05 4:14 
GeneralRe: Conversion of C++ templates into C code Pin
Jörgen Sigvardsson29-Jun-05 12:37
Jörgen Sigvardsson29-Jun-05 12:37 
GeneralRe: Conversion of C++ templates into C code Pin
toxcct29-Jun-05 5:53
toxcct29-Jun-05 5:53 
GeneralUnicode streams and ASCII files Pin
Patje28-Jun-05 4:19
Patje28-Jun-05 4:19 
GeneralRe: Unicode streams and ASCII files Pin
valikac28-Jun-05 11:38
valikac28-Jun-05 11:38 
GeneralRe: Unicode streams and ASCII files Pin
Patje28-Jun-05 12:28
Patje28-Jun-05 12:28 
GeneralRe: Unicode streams and ASCII files Pin
valikac28-Jun-05 12:38
valikac28-Jun-05 12:38 
GeneralRe: Unicode streams and ASCII files Pin
Bobby Mihalca30-Jun-05 22:25
Bobby Mihalca30-Jun-05 22:25 
Streams are transparent, you should use locale codecvt facet so that the buffer will be converted before saving and after loading.
Your code should look like this:

<br />
std::wofstream myfile;<br />
//myfile.setMode (ascii or unicode);<br />
std::locale loc(std::locale(),new std::codecvt<wchar_t,ascii ? char : wchar_t,std::mbstate_t>());<br />
myfile.imbue(loc);<br />
<br />
<br />
myfile.open ("output.txt");<br />
myfile << reportHeader << std::endl;<br />
for (all columns) myfile << columnname;<br />
myfile << std::endl;<br />
for (all records)<br />
{<br />
for (all columns) myfile << data;<br />
myfile << std::endl;<br />
}<br />


Note that myfile is always wchar_t and codecvt converts the caracters to char.
If your internal data is char based you should use a char based stream and imbue it with a codecvt that converts from char to wchar_t is you need to save Unicode.
Also when saving to Unicode you should write 0xEF 0xBB 0xBF first to indicate the file is Unicode (is what you will find at the beginning of utf-16 xml files) and when reading the file read the first 3 bytes, test them and then use the right codecvt facet to convert to your internal data.
GeneralRe: Unicode streams and ASCII files Pin
valikac1-Jul-05 8:19
valikac1-Jul-05 8:19 
Generalofstream adding in start of file Pin
SimpleProgramer28-Jun-05 0:56
SimpleProgramer28-Jun-05 0:56 
GeneralRe: ofstream adding in start of file Pin
CP Visitor28-Jun-05 6:57
CP Visitor28-Jun-05 6:57 
GeneralSTL Deque problem...again ! Pin
mmagnani7127-Jun-05 23:27
mmagnani7127-Jun-05 23:27 
GeneralRe: STL Deque problem...again ! Pin
Stuart Dootson28-Jun-05 21:36
professionalStuart Dootson28-Jun-05 21:36 
GeneralRe: STL Deque problem...again ! Pin
mmagnani7128-Jun-05 22:54
mmagnani7128-Jun-05 22:54 
GeneralProblems with toolbar when using TBSTYLE_EX_MIXEDBUTTONS Pin
retro_coder27-Jun-05 21:43
retro_coder27-Jun-05 21:43 
GeneralSTL Notation Pin
Jack Puppy27-Jun-05 17:20
Jack Puppy27-Jun-05 17:20 
GeneralRe: STL Notation Pin
Christian Graus27-Jun-05 18:17
protectorChristian Graus27-Jun-05 18:17 
GeneralRe: STL Notation Pin
Douglas Troy1-Jul-05 7:01
Douglas Troy1-Jul-05 7:01 
Questiondoes BHO have max memory limit? Pin
petevam26-Jun-05 23:11
petevam26-Jun-05 23:11 
AnswerRe: does BHO have max memory limit? Pin
Douglas Troy27-Jun-05 4:47
Douglas Troy27-Jun-05 4:47 
GeneralRe: does BHO have max memory limit? Pin
petevam27-Jun-05 6:20
petevam27-Jun-05 6:20 
GeneralDS_FIXEDSYS in WTL project VS2005 Pin
vassilux@26-Jun-05 4:18
vassilux@26-Jun-05 4:18 
GeneralRe: DS_FIXEDSYS in WTL project VS2005 Pin
toxcct26-Jun-05 5:19
toxcct26-Jun-05 5:19 
GeneralRe: DS_FIXEDSYS in WTL project VS2005 Pin
Jörgen Sigvardsson26-Jun-05 5:59
Jörgen Sigvardsson26-Jun-05 5:59 
GeneralRe: DS_FIXEDSYS in WTL project VS2005 Pin
vassilux@26-Jun-05 9:03
vassilux@26-Jun-05 9:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.