Question

I have a Korean string: "태권소녀 1". And now I want to remove a substring, " 1" (a space and '1' character). How can I do it in C++?

With the English string it works ok, but I cannot do it with Korean yet.

Thank you so much if you can give me some ideas.

Was it helpful?

Solution

thestring.erase(thestring.find(" 1"),2);

assuming, it's there. This is not the code to use it's a hint about what to look up in the documentation.

The problem you have is probably to determine the size in bytes of the particular string in characters. It depends on the encoding, but generally you may want to look at the family of functions with mb in their names (which stands for multibyte).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top