Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 55635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T17:24:30+00:00 2026-05-10T17:24:30+00:00

I have a problem with a string in C++ which has several words in

  • 0

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 accented counterparts. Example: I want to replace this word: ‘había’ for habia. I tried replace it directly but with replace method of string class but I could not get that to work.

I’m using this code:

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);     } } 

Where dictionary is a map like this (with more entries):

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') ); 

and toReplace strings is:

std::string toReplace='á-é-í-ó-ú-ñ-á-é-í-ó-ú-ñ'; 

I obviously must be missing something. I can’t figure it out. Is there any library I can use?.

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T17:24:30+00:00Added an answer on May 10, 2026 at 5:24 pm

    First, this is a really bad idea: you’re mangling somebody’s language by removing letters. Although the extra dots in words like “naïve” seem superfluous to people who only speak English, there are literally thousands of writing systems in the world in which such distinctions are very important. Writing software to mutilate someone’s speech puts you squarely on the wrong side of the tension between using computers as means to broaden the realm of human expression vs. tools of oppression.

    What is the reason you’re trying to do this? Is something further down the line choking on the accents? Many people would love to help you solve that.

    That said, libicu can do this for you. Open the transform demo; copy and paste your Spanish text into the “Input” box; enter

    NFD; [:M:] remove; NFC 

    as “Compound 1” and click transform.

    (With help from slide 9 of Unicode Transforms in ICU. Slides 29-30 show how to use the API.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interesting problem, which is a function that returns a Dictionary<String,HashSet<String>> .
I have a Log class that has several static methods which help log information
My particular problem: I have a string which specifies an aribitrary type in a
I am using LaTeX and I have a problem concerning string manipulation. I want
I have a problem that output string must be utf8-formatted, I am writing currently
I have a SQL Server 2008 database. This database has a stored procedure that
I know this question has been asked several times for sure, but I have
I have a settings bundle in an iPhone app which has several subtle variant
I have an existing database based on SQLiteOpenHelper that has several versions and code
I have a problem converting a string binary to a decimal I was using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.