wstring convert for mpt

This commit is contained in:
Concedo 2023-06-24 11:43:42 +08:00
parent 6d718525c4
commit 0485fa65a2
5 changed files with 30 additions and 7 deletions

View file

@ -122,8 +122,14 @@ std::string convert_to_utf8(const std::wstring & input) {
std::wstring convert_to_wstring(const std::string & input) {
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
return converter.from_bytes(input);
try {
std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
return converter.from_bytes(input);
} catch (const std::range_error& e) {
return L"";
} catch (...) {
return L"";
}
}
void gpt_split_words(std::string str, std::vector<std::string>& words) {