mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-30 17:24:08 +00:00
Win-specific: Update OpenCC library
This commit is contained in:
parent
249db51e86
commit
c689487614
|
@ -140,11 +140,11 @@ public:
|
||||||
size_t NumValues() const { return values.size(); }
|
size_t NumValues() const { return values.size(); }
|
||||||
|
|
||||||
vector<const char*> Values() const {
|
vector<const char*> Values() const {
|
||||||
vector<const char*> values;
|
vector<const char*> retsult;
|
||||||
for (const string& value : this->values) {
|
for (const string& value : this->values) {
|
||||||
values.push_back(value.c_str());
|
retsult.push_back(value.c_str());
|
||||||
}
|
}
|
||||||
return values;
|
return retsult;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
namespace opencc {
|
namespace opencc {
|
||||||
|
|
||||||
class OPENCC_EXPORT Exception : public std::exception {
|
class OPENCC_EXPORT Exception {
|
||||||
public:
|
public:
|
||||||
Exception() {}
|
Exception() {}
|
||||||
|
|
||||||
|
|
|
@ -262,20 +262,22 @@ public:
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
static std::string U16ToU8(const std::wstring& wstr) {
|
static std::string U16ToU8(const std::wstring& wstr) {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
int convcnt = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), NULL, 0, NULL, NULL);
|
int length = static_cast<int>(wstr.length());
|
||||||
|
int convcnt = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, NULL, 0, NULL, NULL);
|
||||||
if (convcnt > 0) {
|
if (convcnt > 0) {
|
||||||
ret.resize(convcnt);
|
ret.resize(convcnt);
|
||||||
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), &ret[0], convcnt, NULL, NULL);
|
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), length, &ret[0], convcnt, NULL, NULL);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::wstring U8ToU16(const std::string& str) {
|
static std::wstring U8ToU16(const std::string& str) {
|
||||||
std::wstring ret;
|
std::wstring ret;
|
||||||
int convcnt = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0);
|
int length = static_cast<int>(str.length());
|
||||||
|
int convcnt = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, NULL, 0);
|
||||||
if (convcnt > 0) {
|
if (convcnt > 0) {
|
||||||
ret.resize(convcnt);
|
ret.resize(convcnt);
|
||||||
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &ret[0], convcnt);
|
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), length, &ret[0], convcnt);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue