Spaces:
Running
Running
Judd
Judd
commited on
Fixes for Windows (#2790)
Browse filesFixes for Windows:
* MSVC default to utf-8 without BOM.
* Console output code page changed to utf-8.
---------
Co-authored-by: Judd <[email protected]>
- cmake/build-info.cmake +2 -0
- examples/cli/cli.cpp +12 -0
cmake/build-info.cmake
CHANGED
|
@@ -42,6 +42,8 @@ endif()
|
|
| 42 |
if(MSVC)
|
| 43 |
set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
|
| 44 |
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
|
|
|
|
|
|
|
| 45 |
else()
|
| 46 |
execute_process(
|
| 47 |
COMMAND sh -c "$@ --version | head -1" _ ${CMAKE_C_COMPILER}
|
|
|
|
| 42 |
if(MSVC)
|
| 43 |
set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
|
| 44 |
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
|
| 45 |
+
add_compile_options("$<$<COMPILE_LANGUAGE:C>:/utf-8>")
|
| 46 |
+
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:/utf-8>")
|
| 47 |
else()
|
| 48 |
execute_process(
|
| 49 |
COMMAND sh -c "$@ --version | head -1" _ ${CMAKE_C_COMPILER}
|
examples/cli/cli.cpp
CHANGED
|
@@ -12,6 +12,11 @@
|
|
| 12 |
#include <vector>
|
| 13 |
#include <cstring>
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
#if defined(_MSC_VER)
|
| 16 |
#pragma warning(disable: 4244 4267) // possible loss of data
|
| 17 |
#endif
|
|
@@ -916,6 +921,13 @@ static bool output_lrc(struct whisper_context * ctx, const char * fname, const w
|
|
| 916 |
static void cb_log_disable(enum ggml_log_level , const char * , void * ) { }
|
| 917 |
|
| 918 |
int main(int argc, char ** argv) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 919 |
whisper_params params;
|
| 920 |
|
| 921 |
// If the only argument starts with "@", read arguments line-by-line
|
|
|
|
| 12 |
#include <vector>
|
| 13 |
#include <cstring>
|
| 14 |
|
| 15 |
+
#if defined(_WIN32)
|
| 16 |
+
#define NOMINMAX
|
| 17 |
+
#include <windows.h>
|
| 18 |
+
#endif
|
| 19 |
+
|
| 20 |
#if defined(_MSC_VER)
|
| 21 |
#pragma warning(disable: 4244 4267) // possible loss of data
|
| 22 |
#endif
|
|
|
|
| 921 |
static void cb_log_disable(enum ggml_log_level , const char * , void * ) { }
|
| 922 |
|
| 923 |
int main(int argc, char ** argv) {
|
| 924 |
+
#if defined(_WIN32)
|
| 925 |
+
// Set the console output code page to UTF-8, while command line arguments
|
| 926 |
+
// are still encoded in the system's code page. In this way, we can print
|
| 927 |
+
// non-ASCII characters to the console, and access files with non-ASCII paths.
|
| 928 |
+
SetConsoleOutputCP(CP_UTF8);
|
| 929 |
+
#endif
|
| 930 |
+
|
| 931 |
whisper_params params;
|
| 932 |
|
| 933 |
// If the only argument starts with "@", read arguments line-by-line
|