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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 140k
  • Answers 140k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This aught to do it: SELECT * FROM MyTable WHERE… May 12, 2026 at 7:50 am
  • Editorial Team
    Editorial Team added an answer You want to use the rank function in T-SQL: select… May 12, 2026 at 7:50 am
  • Editorial Team
    Editorial Team added an answer You could do all of your logging inside an error… May 12, 2026 at 7:50 am

Related Questions

I'm lead dev for Bitfighter , and we're working with a mix of Lua
I have a very painful library which, at the moment, is accepting a C#
I wrote a file parser for a game I'm writing to make it easy
I have a couple of array's: const string a_strs[] = {cr=1, ag=2, gnd=U, prl=12,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.