スペイン語の単語がいくつかあるC++の文字列に問題があります。これは、アクセントやチルダのある単語がたくさんあることを意味します。アクセントのないものと交換したいと思います。例:この単語を置き換えたい:habiaの「había」。直接置き換えてみましたが、文字列クラスのreplaceメソッドを使って置き換えましたが、うまくいきませんでした。
私はこのコードを使用しています:
for (it= dictionary.begin(); it != dictionary.end(); it++)
{
strMine=(it->first);
found=toReplace.find_first_of(strMine);
while (found!=std::string::npos)
{
strAux=(it->second);
toReplace.erase(found,strMine.length());
toReplace.insert(found,strAux);
found=toReplace.find_first_of(strMine,found+1);
}
}
このようなマップはどこdictionary
にありますか(より多くのエントリがあります):
dictionary.insert ( std::pair<std::string,std::string>("á","a") );
dictionary.insert ( std::pair<std::string,std::string>("é","e") );
dictionary.insert ( std::pair<std::string,std::string>("í","i") );
dictionary.insert ( std::pair<std::string,std::string>("ó","o") );
dictionary.insert ( std::pair<std::string,std::string>("ú","u") );
dictionary.insert ( std::pair<std::string,std::string>("ñ","n") );
toReplace
文字列は次のとおりです。
std::string toReplace="á-é-í-ó-ú-ñ-á-é-í-ó-ú-ñ";
私は明らかに何かが欠けているに違いありません。私はそれを理解することはできません。使用できるライブラリはありますか?
ありがとう、