Question

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

Was it helpful?

Solution

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

See this article for further info

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top