VS2019: How to resolve the "unknown sub-lang: 0x8" message in Resource View?
Asked Answered
F

8

7

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.

enter image description here

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://learn.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

Fennell answered 4/6, 2019 at 9:56 Comment(0)
G
6

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).

Giddings answered 7/8, 2019 at 20:12 Comment(2)
And between explicit English (LANG_ENGLISH) and Default (LANG_NEUTRAL) which seems to exist even if you don't choose it. What is the best to store English?Circus
Good question. As I see it, you place a string as Neutral when it is the same for multiple/all languages ... e.g. the name of the company or application. And language specific strings in their LANG_ section. If you really only have one language then there is no big difference I guess, but would suggest to use LANG_ENGLISH (that is: the ID for your language) for future extensibility. More details here: learn.microsoft.com/en-us/windows/win32/intl/…Giddings
T
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)

Tsaritsyn answered 29/8, 2019 at 6:55 Comment(0)
F
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.

Fennell answered 5/6, 2019 at 7:30 Comment(2)
Although I found this solution in another forum also, it did not help with me.Giddings
@msof Actually I did not convert it to UTF-8, I converted it to UNICODE (in note pad - I assume this is UTF-16) - And it did the trick.Renowned
I
1

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://learn.microsoft.com/en-us/windows/win32/intl/code-page-identifiers and https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-makelangid#remarks

Ibert answered 19/9, 2019 at 12:26 Comment(0)
R
1

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.

Renowned answered 28/6, 2020 at 11:1 Comment(1)
This worked for me too. Saved it to Unicode.Workshop
G
0

I've found a solution that worked for me.

  1. Open the *.rc file in the 'Code View' in Visual Studio.
  2. Search for the following section:
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD)
LANGUAGE LANG_NEUTRAL, SUBLANG_SYS_DEFAULT
#pragma code_page(1252)
...
  1. Comment the complete #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUSD) block and save the file.

  2. Open the file in the 'Resource View'. Close it. (Maybe you have to change and save something here)

  3. 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

Glarus answered 23/3, 2020 at 9:14 Comment(0)
C
0

I've fought with this for a while, trying different combinations of LANGUAGE options and encodings.

In my case, the trick was, not just converting RC file to UTF-8, but to «UTF-8 with BOM».

To summarise this, when a problem with loading RC-file into Visual Studio in encountered, the first thing to do is try to save the file using a different UTF encoding:

  • UTF-8 with BOM (helped in my case)
  • UTF-8 without BOM
  • UTF-16 LE (depends on the architecture)
  • UTF-16 BE (depends on the architecture)

Moreover, I want to mention, that if you use CMake templates to generate RC file, the original encoding in template (.in file) will be preserved.

The second part is to check if the Language Identifier Constants and Strings are correct.

The correct way to set Neutral language set is described on the official page:

If there is no sublanguage identifier to use with a primary language identifier, your application should use SUBLANG_DEFAULT. It should use SUBLANG_NEUTRAL for resources that are the same for all sublanguages of a primary language.

LANGUAGE LANG_NEUTRAL, SUBLANG_DEFAULT

Additional information about can be found here:

Stack Overflow: Visual Studio Resource Editor corrupts rc files with UTF-8 encoding

Clem answered 3/4 at 9:10 Comment(0)
S
0

Changing the file to UTF-8 has the problem, that in the Editor the Texts are not shown correct. In my case:

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DES)
LANGUAGE LANG_GERMAN, SUBLANG_GERMAN_SWISS
#pragma code_page(1252)

I installed the German(Switzerland) Language Pack and set regional format to this Sublanguage on my Windows 10, and it worked again as expected.

Subchloride answered 27/5 at 11:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.