Skip to content

Commit 4f4f2e1

Browse files
author
Jules
committed
fix Windows text encoding issue causing infinite loop
1 parent eb141a0 commit 4f4f2e1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

examples/text/uie/cpp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
PROJECT(infer_demo C CXX)
1616
CMAKE_MINIMUM_REQUIRED (VERSION 3.10)
17+
if(MSVC)
18+
add_definitions(/utf-8)
19+
endif()
1720

1821
option(FASTDEPLOY_INSTALL_DIR "Path of downloaded fastdeploy sdk.")
1922

examples/text/uie/cpp/infer.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
#include "fastdeploy/text.h"
1919

20+
#ifdef WIN32
21+
#include <windows.h>
22+
#endif
23+
2024
using namespace paddlenlp;
2125

2226
#ifdef WIN32
@@ -77,6 +81,9 @@ int main(int argc, char* argv[]) {
7781
predictor.Predict({"2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷"
7882
"爱凌以188.25分获得金牌!"},
7983
&results);
84+
#ifdef WIN32
85+
SetConsoleOutputCP(CP_UTF8);
86+
#endif
8087
std::cout << results << std::endl;
8188
results.clear();
8289

0 commit comments

Comments
 (0)