Skip to content

Commit 2b70a1c

Browse files
author
Judd
committed
Fixes for Windows:
* MSVC default to utf-8 without BOM. * Console output code page changed to utf-8.
1 parent 33ea03f commit 2b70a1c

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

cmake/build-info.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ endif()
4242
if(MSVC)
4343
set(BUILD_COMPILER "${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}")
4444
set(BUILD_TARGET ${CMAKE_VS_PLATFORM_NAME})
45+
add_compile_options("/utf-8")
4546
else()
4647
execute_process(
4748
COMMAND sh -c "$@ --version | head -1" _ ${CMAKE_C_COMPILER}

examples/cli/cli.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
#include <vector>
1313
#include <cstring>
1414

15+
#if defined(_WIN32)
16+
#define NOMINMAX
17+
#include <windows.h>
18+
#endif
19+
1520
#if defined(_MSC_VER)
1621
#pragma warning(disable: 4244 4267) // possible loss of data
1722
#endif
@@ -915,7 +920,14 @@ static bool output_lrc(struct whisper_context * ctx, const char * fname, const w
915920

916921
static void cb_log_disable(enum ggml_log_level , const char * , void * ) { }
917922

918-
int main(int argc, char ** argv) {
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+
919931
whisper_params params;
920932

921933
// If the only argument starts with "@", read arguments line-by-line

0 commit comments

Comments
 (0)