How to compile the source text to UTF-8 without BOM in Visual Studio?
Project source code is stored in UTF-8 format without BOM. When you build the project in Visual Studio there is the problem of displaying UTF, like other encoding. When you save source files in UTF-8 with BOM, the problem of character display disappears.
You must keep the source code format without BOM, how do you make cl.exe to accept UTF-8 without BOM as uniatowski?
2 answers
A philosophical reply from TO: store localizable resources separately from the code (in an. rc file or something like that). Trifle (individual characters) specify using escape sequences.
Remains the problem with the review (will be gibberish), but to come out properly.
According to official documents is currently supported three formats of the source files: utf16 bom, utf16 w/o bom, the utf8 bom.
Unfortunately, utf8 w/o bom is not supported.
For myself, I found a few spike solutions:
- To do pre build script for converting files to utf8 bom and post build script to convert files to utf8 w/o bom
- Make the automatic conversion of the file as utf8 in visual studio. If you are using a version control system (like me, for example), then do pre-commit hook to convert to utf8 w/o bom
Are there any more opinions on the sequel?
Find more questions by tags UnicodeVisual Studio