We have a commenting system built into our engine that allows programmers to put comments for various exposed variables/objects which are then used by the GUI front-end for tool-tips and help.
Recently, certain tool-tips started crashing, and after much wasted time I tracked it down to the the character: ’ which, unless I am mistaken, is a unicode character and not available in ASCII.
Taking this answer into consideration, I assumed wstring would fix the problem. Before making changes in the bigger project, I created a test project to see if wstring would solve the issue. Although the project doesn't crash, the behavior is not as expected for wstring.
#include <iostream> #include <string> using namespace std; int main() { string someString = "successive attack that DOESN’T result"; wstring someWString = L"successive attack that DOESN’T result"; cout << someString << endl; wcout << someWString << endl; return 0; } //Console Output// successive attack that DOESNÆT result successive attack that DOESNPress any key to continue . . . I read this article quite some time ago and thought I understood the problems associated with character sets, but that is obviously not the case. I would appreciate a solution to this problem as well as a good explanation of what is happening and how to avoid problems similar to this in the future.
Use Multi-byte Character SetandUse Unicode Character Setwith no difference in the output.wstringso I thought I'd try on a smaller project before making the changes and finding out they did not fix the problem.