This commit is contained in:
lenheart
2024-10-24 10:06:35 +08:00
parent 7348bbdd14
commit d803ea8fe0
6 changed files with 17 additions and 13 deletions

View File

@@ -10,7 +10,7 @@
#include "croncpp.h"
#include "l_socket.h"
#include <openssl/md5.h>
#include <opencc/opencc.h>
// #include <opencc/opencc.h>
#include <iostream>
#include <functional>
#include <list>
@@ -942,18 +942,18 @@ static SQInteger L_Conversion(HSQUIRRELVM v)
sq_getinteger(v, 3, &Type);
std::string traditionalStr = std::string(Str);
sq_pushnull(v);
// opencc_t ot;
// if (Type == 0)
// ot = opencc_open(OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP);
// else if (Type == 1)
// ot = opencc_open(OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD);
opencc_t ot;
if (Type == 0)
ot = opencc_open(OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP);
else if (Type == 1)
ot = opencc_open(OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD);
char *NewStr = opencc_convert_utf8(ot, traditionalStr.c_str(), traditionalStr.length());
std::string RetStr(NewStr);
sq_pushstring(v, RetStr.c_str(), -1);
opencc_convert_utf8_free(NewStr);
opencc_close(ot);
// char *NewStr = opencc_convert_utf8(ot, traditionalStr.c_str(), traditionalStr.length());
// std::string RetStr(NewStr);
// sq_pushstring(v, RetStr.c_str(), -1);
// opencc_convert_utf8_free(NewStr);
// opencc_close(ot);
return 1;
}