Visual Studio 2019 and 2022 Resource Editor is able to correctly read and display .rc file in UTF-8 encoding if .rc file is saved without UTF-8 BOM.
The main requirements for it, .rc file must contain valid #pragma code_page
.
Example:
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NEUD)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(65001)
But if you did some changes in textual resource and saves result back to .rc file, it will be corrupted:
- all
#pragma code_page(65001)
will be replaced by your default ANSI code page (e.g.#pragma code_page(1252)
) - all non ANSI symbol will be replaced by
?
.
Is there some way how to work with UTF-8 c resource in Visual Studio 2019\2022 Resource Editor without this bug.
P.S.:
- I don't use Unicode (UTF-16 LE) encoding due to problems in git with it.
- Using UTF-8 without BOM is single way how to compile UTF-8 .rc file in Visual Studio, see link.
CodePudding user response:
Microsoft knows about this bug and they decided not to fix it:
Thank you very much for your feedback. We've decided to take no action on this feedback at the time.
When working with Resource Compiler (.rc) source files, our suggestion has always been to use UTF-16 whenever resources contain strings that cannot be encoded as ASCII. Based on your replies, it looks like switching back to UTF-16 would unblock your experience with Resource Editor, with the caveat that GitHub won't treat .rc files as text.
While eventually we want to support UTF-8 text encodings for .rc files, we currently do not have plans for this work; and for this reason we're closing this issue as Won't Fix.