C ++ std :: string.replace没有替换,为什么不呢?

时间:2012-11-23 11:11:10

标签: c++ string visual-studio-2008 replace

如果我使用普通字符的string.replace一切顺利,但是一旦我尝试替换像德语“ü”这样的特殊字符,我就没有结果

int main(){
    string s("Gl\\u00fcckstadt");
    string a = "\\u00fc";
    string ue = "ü";
    s = s.replace(s.find(a), a.length(), ue);
    cout << s << endl;
    system("pause");
    return 0;
}

替换doenst替换我需要它替换的字符串,任何我错的建议吗?

int main(){
    string s("Glssckstadt");
    string a = "ss";
    string ue = "ue";
    s = s.replace(s.find(a), a.length(), ue);
    cout << s << endl;
    system("pause");
    return 0;
}

这个将把“ss”替换为“ue”,但是一旦我尝试用“ü”代替它,它就不起作用......

0 个答案:

没有答案
相关问题