I'm having a problem with encoding and don't really know, where to begin. So, I'm going to describe it in detail:
I wrote a little programm with GUI, which has multiple textboxes. The text, that I enter in the textboxes replaces some pattern-words in .txt-files (text is read from a source file and is written in a destination file). It works fine, until I enter German umlauts (öäü). The umlauts are not displayed right in the txt-files, after the patterns are replaced.
What I tried till now:
- Saved the files, both source and destination in UTF-8 encoding
- Tried different text-editors
- Tried the wcstombs function
- Tried codecvt::do_out function (I have to admit, the function is too difficult to understand for me) and I'm not sure, if I have to convert from UTF-16 to UTF-8 and that is my main problem.
I don't know, from what encoding to which to convert and on which stage the encoding is changed by the programm.
This is how the pattern is replaced:
while (getline(fin, temp))
pos1 = 0;
//str1 is the pattern-string
while ((pos1 = temp.find(str1, pos1)) != string::npos)
temp.replace(pos1, str1.size(), (context.marshal_as<std::string>(mainField->Text)));
This is what the entered string looks like in the file, when I enter "ASDäöü": http://picload.org/image/oicaldg/unbenannt.png
I really hope, that you can help me with this.
Thank you in advance!