Skip to main content
Code Review

Return to Question

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

This question This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

deleted 22 characters in body; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

C++ Qt - Replacing certain characters in a QString

This question is kinda similar to mine. However, I am using C++ with QtC++ with Qt instead of C#.

Note that some people use a $ instead of s in some words so I want to make sure if a file is called "Ke$ha" that it will come out as "Kesha" or at least "KeSha".Note: Some people use a $ instead of s in some words so I want to make sure if a file is called "Ke$ha" that it will come out as "Kesha" or at least "KeSha".

The way I do it so far and it is not done yet, incomplete, is like this:

So at first I remove all dots from the beginning. No matter how many there are. Then I replace certain characters with no character at all and some with a character like s's' or a depending on what it is.

C++ Qt - Replacing certain characters in a QString

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

Note that some people use a $ instead of s in some words so I want to make sure if a file is called "Ke$ha" that it will come out as "Kesha" or at least "KeSha".

The way I do it so far and it is not done yet is like this:

So at first I remove all dots from the beginning. No matter how many there are. Then I replace certain characters with no character at all and some with a character like s or a depending on what it is.

Replacing certain characters in a QString

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

Note: Some people use a $ instead of s in some words so I want to make sure if a file is called "Ke$ha" that it will come out as "Kesha" or at least "KeSha".

The way I do it so far, incomplete, is like this:

So at first I remove all dots from the beginning. No matter how many there are. Then I replace certain characters with no character at all and some with a character like 's' or a depending on what it is.

Source Link
Davlog
  • 677
  • 2
  • 7
  • 15

C++ Qt - Replacing certain characters in a QString

This question is kinda similar to mine. However, I am using C++ with Qt instead of C#.

How would I efficiently and easily remove all accents and special characters like !"§$%&/()=? etc. from a QString ?

So "áche" should turn into "ache" or "über dir" to "ueber dir" (in german ü,ä,ö can be changed into the normalized character with an e appended) or at least "uber dir".

Note that some people use a $ instead of s in some words so I want to make sure if a file is called "Ke$ha" that it will come out as "Kesha" or at least "KeSha".

The way I do it so far and it is not done yet is like this :

void Utils::replaceInvalidChars(QString &str)
{
 if( str.size() == 0 )
 return;
 while( str.at(0) == '.' ) {
 str.remove(0,1);
 }
 str.replace( "/", "-" );
 str.replace( "|", "" );
 str.replace( ":", "-" );
 str.replace("\"", "" );
 str.replace( "?", "" );
 str.replace( "$", "s" );
 str.replace( "*", "" );
 str.replace( ",", "" );
 str.replace( "¿", "" );
 str.replace( "¡", "" );
 str.replace( "!", "" );
 str.replace( "'", "" );
 str.replace( "ë", "e" );
 str.replace( "ê", "e" );
 str.replace( "é", "e" );
 str.replace( "è", "e" );
 str.replace( "ç", "c" );
 str.replace( "ó", "o" );
 str.replace( "ö", "oe" );
 //U's...
 str.replace( "ü", "ue" );
 str.replace( "Ü", "U" );
 str.replace( "ù", "u" );
 str.replace( "Ù", "U" );
 str.replace( "û", "u" );
 str.replace( "Û", "u" );
 //ns
 str.replace( "ñ", "n" );
 //as
 str.replace( "ä", "ae" );
 str.replace( "Ä", "ae" );
 str.replace( "á", "a" );
 str.replace( "Á", "A" );
 str.replace( "à", "a" );
 str.replace( "À", "A" );
 str.replace( "ï", "i" );
}

So at first I remove all dots from the beginning. No matter how many there are. Then I replace certain characters with no character at all and some with a character like s or a depending on what it is.

My way is very long, tedious and chaotic. I am about to organize it a little with comments like "N's", "U's" etc. but still, if I make a mistake somewhere it will take way too long until I (eventually) find it.

lang-cpp

AltStyle によって変換されたページ (->オリジナル) /