为什么特殊字符从文件中读取为false

时间:2010-02-12 22:16:02

标签: c++ special-characters ifstream ofstream

我的程序将一些设置(主要是字符串)保存到文本文件中,以便稍后检索它们,但是唉!特殊字符无法识别!

saveSettings逐个保存字符串......

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

loadSettings检索它们......

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;
    ...

某些文字包含字母'é',后缀为'8'

谢谢您的任何提示

2 个答案:

答案 0 :(得分:2)

也许您应该考虑使用getline的unicode版本:)

有关详细信息,请参阅this article

答案 1 :(得分:2)

尝试将ios::binary添加到流构造函数标记中。

相关问题