ios::binary issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlekseyUS
    New Member
    • Sep 2006
    • 10

    ios::binary issue

    Hi, I'm a little stuck,

    I basically need to copy all the information within a specific file in Temp and append it to a file in another location.

    I'm not having any problems with smaller size log files stored within temp foldier and everything reads and appends perfectly, however when i try to read and append from IS12Install.log file in Temp all it appends to my destination file is:

    ÿþ=
    and a whole bunch of empty lines

    I believe that this is an encoding issue..
    I thought that i might solve this by using the binary read and binary write(append) ios::binary to get around this issue...

    1) Why is this happening? I've noticed that the log file is 2.5mb might this be the issue?

    2) Will ios::binary solve this issue?

    3) If i do read and write(append) binary what i need to do to convert the binary back to letters before i write(append) the information?

    4) Any other ideas of what might be happening and how to solve this issue?

    Here is a chunk of my code:

    //OPEN BOTH SOURCE AND DESTINATION FILES FOR READING AND WRITING/APPENDING
    fstream file_in(SrcFile ,ios::in);
    fstream file_out(DestFi le,ios::app);

    //READ FROM SOURCE FILE
    //APPEND EVERYTHING TO DESTINATION
    char str[2000];

    while(!file_in. eof())
    {
    file_in.getline (str,2000);
    file_out << "\n" << str;
    }
    file_out << endl;

    //CLOSE BOTH SOURCE AND DESTINATION FILES
    file_in.close() ;
    file_out.close( );

    Thanks in advance
    Alex
  • AlekseyUS
    New Member
    • Sep 2006
    • 10

    #2
    Ok apparently i found out more about what is happening:

    the .log file that i'm having problems with is in Unicode... so i have to read the Unicode line by line convert it to normal characters and write it to my Destination Log File...

    I was told that unless i use cstring i won't be able to read the Unicode correctly...is this true?

    Also what would be the best way going about doing what i described?

    Thanks for all the help

    Alex

    Comment

    Working...