Answer the question
In order to leave comments, you need to log in
How to compile UTF-8 source without BOM in Visual Studio?
The project source code is stored in UTF-8 format without BOM. When building a project in Visual Studio, there is a problem displaying UTF characters as if they were a different encoding. When saving source code files in UTF-8 format with BOM, the problem of displaying characters disappears.
It is necessary to store the source code in a format without BOM, how can I make cl.exe treat UTF-8 without BOM as Unicode?
Answer the question
In order to leave comments, you need to log in
Philosophical answer from KO: keep localizable resources separate from code (in rc-files or something like that). Trifle (individual characters) to set through escape sequences.
There will be a problem with comments (there will be abracadabra), but everything should be assembled correctly.
According to the official documentation, three source code file formats are currently supported: utf16 bom, utf16 w/o bom, utf8 bom.
Unfortunately utf8 w/o bom is not supported.
For myself, I found several crutch solutions:
- Make pre build script to convert files to utf8 bom and post build script to convert files to utf8 w/o bom
- Make automatic file conversion as utf8 in visual studio. If a version control system is used (like mine, for example), then do a pre-commit hook to convert to utf8 w/o bom
Any other opinions on how to proceed?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question