mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
Explicitly declare that source files are UTF-8
Before this change, there was a chance that a text editor or compiler would use the wrong character encoding. For text editors, this commit adds “charset = utf-8” to .editorconfig. That will cause editors that support EditorConfig files [1] to automatically use UTF-8 when reading and writing files. For compilers, this commit adds compiler options that guarantee that compilers will decode source code files using UTF-8. The compiler options are known to work on MSVC, GCC and Clang. If we ever want to support additional compilers, then we might have to edit the if statement that this commit adds. This commit does not eliminate the chance that a wrong character encoding will be used. Someone could always use a text editor that doesn’t support EditorConfig files or a compiler that doesn’t support the compiler options that we use. This commit does, however, make an encoding mismatch much less likely. [1]: <https://editorconfig.org/#pre-installed>
This commit is contained in:
parent
308d82e276
commit
dd757e9034
@ -5,6 +5,7 @@ indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 8
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
spelling_language = en-US
|
||||
|
||||
[*.md]
|
||||
|
@ -28,6 +28,12 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
if(MSVC)
|
||||
add_compile_options(/source-charset:UTF-8)
|
||||
else()
|
||||
add_compile_options(-finput-charset=UTF-8)
|
||||
endif()
|
||||
|
||||
if(FORCE_COLORED_OUTPUT)
|
||||
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
|
||||
set(CMAKE_COLOR_DIAGNOSTICS ON)
|
||||
|
Loading…
Reference in New Issue
Block a user