I'm trying to replace a string containing the characters 'åäö'. It's easy to std::cout them directly to the screen, replacing them was a bit trickier though. This is my solution:
If you can't see which characters I mean, it's character (134,132,148)
http://www.asciitable.com/
Code:
#include <iostream>
#include <string>
using namespace std;
int main(void) {
string str = "0123456789 abcdefghijklmnopqrstuvxyz åäö";
str.replace(str.find("å"), str.find("å")+1, "\x86");
str.replace(str.find("ä"), str.find("ä")+1, "\x84");
str.replace(str.find("ö"), str.find("ö")+1, "\x94");
str.replace(str.find("Å"), str.find("Å")+1, "\x8F");
str.replace(str.find("Ä"), str.find("Ä")+1, "\x8E");
str.replace(str.find("Ö"), str.find("Ö")+1, "\x99");
for (int i=0;i<str.size();i++) {
cout << str[i];
}
cin.ignore(cin.rdbuf()->in_avail()+1);
cin.get();
return 0;
}
How would you do, if you wanted to replace the string like I want to. It works sometimes which is quite weird. Right now I only get run-time errors though.