Closed benojan closed 2 years ago
我下载的是wiki里的预编译:https://github.com/BYVoid/OpenCC/wiki/Download 使用下列代码编译:
#include <iostream> #include "opencc/opencc.h" using namespace std; #pragma comment(lib, "opencc.lib") int main() { string str = "中华"; const opencc::SimpleConverter converter("share\\opencc\\s2t.json"); str = converter.Convert(str.c_str()); system("chcp 65001"); cout << "result is " << str << endl; }
如果将上方代码以“无bom的utf8”保存,正常通过。 但是以“有bom的utf8”编码保存时,str = converter.Convert(str.c_str()); 就报错。
str = converter.Convert(str.c_str());
我最终是打算用于MFC程序内,MFC程序似乎只支持带BOM的utf8。
解決了,貌似是編碼問題
可以看下你的VS项目配置吗?
我下载的是wiki里的预编译:https://github.com/BYVoid/OpenCC/wiki/Download 使用下列代码编译:
如果将上方代码以“无bom的utf8”保存,正常通过。 但是以“有bom的utf8”编码保存时,
str = converter.Convert(str.c_str());
就报错。我最终是打算用于MFC程序内,MFC程序似乎只支持带BOM的utf8。