views:

61

answers:

2

Hi my program saves some settings (mostly string) to a text file, to retrieve them later, but alas! The special characters come back unrecognizable!

saveSettings saves the strings one by one...

void email::saveSettings(string filename){
    ofstream savefile(filename.c_str(),ios::out | ios::trunc);
    email settingsemail(this);
    savefile <<mailprog<<endl;
    ...

loadSettings retrieves them...

bool loadSettings(string filename){
    char chtemp[255];
    ifstream savefile(filename.c_str(), ios::in);
    if (savefile.is_open()){
    savefile.getline(chtemp,255);
    mailprog=chtemp;
    savefile.getline(chtemp,255);
    smtp=chtemp;
    ...

some text includes the letter 'é', which is read back as '8'

thank you for any hint

+2  A: 

Maybe you should consider use a unicode version of getline : )

See this article for further info

SDReyes
+1  A: 

Try adding ios::binary to your stream constructor flags.

JonM