I am developing a Win32 desktop application with C++ where the target-language is Swedish. As a result of that I rely on Unicode to properly format and display any given string. However, I encountered a very peculiar issue where strings consisting of non-english characters (such as å, ä, ö) work in one part of the code, but breaks in another part of the code.
More specifically, the code works in one file, but not the other. If I move the code-block to the other file, then the text is properly displayed again. See the following example:
CreateWindowW(L"Button", L"Lägg till kund", WS_TABSTOP | WS_VISIBLE | WS_CHILD,
0, 0, 80, 25, windowHandle, (HMENU)0, NULL, NULL);
-Which is called from the Application.cpp file.
AppendMenu(m_MainMenuBar, MF_POPUP, (UINT_PTR)m_ArkivMenu, L"&Arkiv");
AppendMenu(m_MainMenuBar, MF_POPUP, (UINT_PTR)m_VisaMenu, L"&Visa");
AppendMenu(m_MainMenuBar, MF_POPUP, (UINT_PTR)m_ArkivMenu, L"&Hjälp");
AppendMenu(m_MainMenuBar, MF_POPUP, (UINT_PTR)m_ArkivMenu, L"&Sök");
-Which is called from the Window.cpp file.
All of this results in the following:
Note that the code called from Window.cpp generates text with invalid characters, which indicates that the symbol(s) couldn't be found. This is very strange since the problem ceases to exist if I move the code from Window.cpp to Application.cpp.
Thus, the only logical conclusion is that the character encoding must differ between these two files, but why?