标签:开源库 out 一个 iostream 自己 命令 utf8 style 示例
//test.cpp
#include <iostream>
#include <opencc/opencc.h>
using namespace std;
int main ( int argc, char *argv[] )
{
string str= "中華人民共和國反分裂國家法";
//string str= "中华人民共和国反分裂国家法";
//默认的是简体转繁体即OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP, opencc.h头文件中有详细介绍
opencc_t ot = opencc_open(OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP);
char buffer[512] = {‘\0‘};
opencc_convert_utf8_to_buffer(ot, str.c_str(), str.size(), buffer);
cout << "result is " << buffer << endl;
opencc_close(ot);
return 0;
}
标签:开源库 out 一个 iostream 自己 命令 utf8 style 示例
原文地址:http://www.cnblogs.com/sxhlinux/p/7269861.html