How to remove accents and tilde in a C++ std::string

前端 未结 8 1388
半阙折子戏
半阙折子戏 2020-12-15 21:26

I have a problem with a string in C++ which has several words in Spanish. This means that I have a lot of words with accents and tildes. I want to replace them for their not

8条回答
  •  太阳男子
    2020-12-15 21:55

    I could not link the ICU libraries but I still think it's the best solution. As I need this program to be functional as soon as possible I made a little program (that I have to improve) and I'm going to use that. Thank you all for for suggestions and answers.

    Here's the code I'm gonna use:

    for (it= dictionary.begin(); it != dictionary.end(); it++)
    {
        strMine=(it->first);
        found=toReplace.find(strMine);
        while (found != std::string::npos)
        {
            strAux=(it->second);
            toReplace.erase(found,2);
            toReplace.insert(found,strAux);
            found=toReplace.find(strMine,found+1);
        }
    } 
    

    I will change it next time I have to turn my program in for correction (in about 6 weeks).

提交回复
热议问题