Adolph
Sat Jan 03 20:39:13 CST 2004
Thanks a lot! I have used the C style of writing files and I am converting
CString to char *.
Adolph.
<r_z_aret@pen_fact.com> wrote in message
news:3ff729f0.113660495@nntp.theworld.com...
> On Fri, 2 Jan 2004 19:23:20 -0500, "Adolph Seema" <ams9331a@rit.edu>
> wrote:
>
> >Hi anyone,
> >
> >I am trying to write to a file both in the root directory and in the
CompactT
> >Flash I get the same problem. Though the file gives me the right amount
of
> >bytes written, only the first character shows in the file. I pasted my
> >complete code below.
> >
> > CString fileTestname( "test2.txt" );
> > CString testMessage( "Coolant Temperature" );
> > //TCHAR pbuf[20] = _T("Coolant Temperature");
> >
> > CFile fileObject;
> >
> > CFileException e;
> >
> > if( !fileObject.Open( fileTestname, CFile::modeCreate |
CFile::modeWrite,
> >&e ) )
> > {
> > AfxMessageBox( TEXT( "Could not open: " )+fileTestname );
> > } else
> > {
> > fileObject.Write( testMessage, testMessage.GetLength() );
>
> I don't use MFC, so I may be off here.
>
> I _think_ you wrote UNICODE text to the file. You would be able to
> read that with at least some programs, but only if you put the
> appropriate BOM (Byte Order Marker) at the beginning of the file to
> let programs know how to read the file (to indicate that it is a
> UNICODE file and to indicate whether it is "big endian" or "little
> endian"). So, one solution is to write the appropriate BOM to each
> file when you create it. For more info you might look at my 2 Jun 03
> contribution to a thread called "File formats from PPC to Windows " in
> microsoft.public.pocketpc.developer. If that isn't sufficient, I
> recommend google (
http://groups.google.com/advanced_group_search).
>
> I actually suggest an alternate approach: translate the text to ASCI
> before writing it. This is the method I used for several years, before
> I knew about the BOM. I know I've seen questions about translating
> CString to ASCII asked and answered, but I don't remember the answer.
> I just used google to look up
> cstring ascii
> in microsoft.public.pocketpc.developer and got 43 hits. I'm pretty
> sure at least one of them will be helpful. If not, tweaking the search
> parameters should succeed quickly.
>
> > }
> >
> > fileObject.Close();
> >
> >What am I doing wrong?
> >
> >Looking forward to your help!
> >Adolph
> >
> >
>
> -----------------------------------------
> To reply to me, remove the underscores (_) from my email address (and
please indicate which newsgroup and message).
>
> Robert E. Zaret
> PenFact, Inc.
> 500 Harrison Ave., Suite 3R
> Boston, MA 02118
> www.penfact.com