forked from doxygen/doxygen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set charset for source and execution on Windows
- For the discussion after doxygen#10084 is merged. - Keep minimal imports in QueryCodePage.py as reviewed
- Loading branch information
1 parent
dfb8542
commit ae6edb5
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
|
||
[*.py] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import platform | ||
|
||
def is_windows(): | ||
return platform.system().lower() == "windows" | ||
|
||
if is_windows(): | ||
from winreg import OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE, KEY_READ | ||
|
||
if __name__ == '__main__': | ||
if is_windows(): | ||
root = HKEY_LOCAL_MACHINE | ||
subkey = R'SYSTEM\CurrentControlSet\Control\Nls\CodePage' | ||
|
||
key = OpenKey(root, subkey, 0, KEY_READ) | ||
name = 'ACP' | ||
|
||
try: | ||
codepage, _ = QueryValueEx(key, name) | ||
print(codepage) | ||
except WindowsError: | ||
print('Failed to get code page') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") | ||
include(FindPythonInterp) | ||
execute_process( | ||
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_SOURCE_DIR}/cmake/QueryCodePage.py" | ||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} | ||
RESULT_VARIABLE ReturnCode | ||
OUTPUT_VARIABLE CodePage | ||
) | ||
message(STATUS "CodePage is ${CodePage}") | ||
if("${CodePage}" STREQUAL "936") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:utf-8 /execution-charset:gbk") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /source-charset:utf-8 /execution-charset:gbk") | ||
else() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8") | ||
endif() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") # /bigobj needed for language.cpp on 64bit | ||
endif() |