问题
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) file in the Resource Viewer. It gives me this warning:
A resource in this file uses an unknown language: Neutral (Default) (unknown sub-lang: 0x8). Unable to open this file.
I tried trimming the resource file to bare necessity but that did not work.
The strange thing is that it also happens with Scribble, Microsofts example project. I downloaded it from https://docs.microsoft.com/en-us/cpp/mfc/walkthrough-updating-the-mfc-scribble-application-part-1?view=vs-2019 using the [Scribble 1.0 MFC sample] link under the Prerequisites header.
When the solution is opened in VS2019, it is converted, it compiles, but I can't open the accompanying resource file to look at the Dialogs.
Any help is appreciated!
Best regards, Keun
回答1:
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).
回答2:
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.
回答3:
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)
回答4:
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
回答5:
I've found a solution that worked for me.
- Open the *.rc file in the 'Code View' in Visual Studio.
- Search for the following section:
#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
回答6:
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.
来源:https://stackoverflow.com/questions/56441565/vs2019-how-to-resolve-the-unknown-sub-lang-0x8-message-in-resource-view