I have recently started using Visual Studio 2019 for my C++11 project. VS2019 converted the project and it compiles into an executable. But I can\'t open my resource (.rc) f
What helped me, was to replace this:
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
(which specifies language English, US with ANSI Latin 1; Western European (Windows) encoding)
By this :
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
#pragma code_page(65001)
(which specifies Language neutral with UTF-8 encoding)
Once I'd made that change (making sure the .rc file was UTF-8 encoded), Visual Studio no longer complained.
See https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers and https://docs.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelangid#remarks
This solution helped for me: https://developercommunity.visualstudio.com/comments/96766/view.html
When you have multiple language settings in your Windows, remove all but one. I had to leave the English (US) option. Then the resource opens again without problems. Hope this helps someone (or myself in the future as this is the second time I spend an hour to search for a solution).
Changing the language actually did not matter in my case, I just converted it to UNICODE (in Microsoft Notepad - I assume this is UTF-16) - And it did the trick.
Note that there is an answer here, regarding UTF-8, which did not work for me.
I've found a solution that worked for me.
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
#pragma code_page(1252)
...
Comment the complete #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
block and save the file.
Open the file in the 'Resource View'. Close it. (Maybe you have to change and save something here)
Reopen the *.rc file via the 'Code View' in Visual Studio. Uncomment the previously commented section and save the file.
After this steps the problem was solved. I don't know which of the steps solved the problem but in the end this was my way to solve the issue.
My solution was inspired by the following solution: https://www.codeproject.com/Questions/40860/Resource-file-opening-problem
The problem is not related to the language setting, but the RC file is stored incorrectly. My file was in ANSI format. As soon as I opened the file with Windows Notepad and saved it as Unicode, I was able to open and edit the resource project in the studio again. (0xFF 0xFE was missing)
Posting my solution for those that encounter similar issues.
I found that the malfunctioning rc files had ANSI encoding. Converting them to UTF-8 did the trick. You can easily do that using Notepad++ via the [Encoding] menu option, select [Convert to UTF-8].
What I don't understand is why VS doesn't fix this itself when converting a project.