SimpCfg:CheckStrings: Switch Mbs2Wcs to multithread safe calls
This commit is contained in:
parent
23acf07bb2
commit
2325764180
1 changed files with 4 additions and 2 deletions
|
@ -45,9 +45,11 @@ size_t wcs_to_mbs(std::string &sDest, const std::wstring &wSrc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t mbs_to_wcs(std::wstring &wDest, std::string &sSrc) {
|
size_t mbs_to_wcs(std::wstring &wDest, std::string &sSrc) {
|
||||||
auto reqLen = std::mbstowcs(nullptr, sSrc.c_str(), 0);
|
std::mbstate_t mbState = std::mbstate_t();
|
||||||
|
const char *sSrcP = sSrc.c_str();
|
||||||
|
auto reqLen = std::mbsrtowcs(nullptr, &sSrcP, 0, &mbState);
|
||||||
wDest.resize(reqLen);
|
wDest.resize(reqLen);
|
||||||
return std::mbstowcs(wDest.data(), sSrc.c_str(), wDest.length());
|
return std::mbsrtowcs(wDest.data(), &sSrcP, wDest.length(), &mbState);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove chars from begin and end of the passed string, provided the char belongs
|
// Remove chars from begin and end of the passed string, provided the char belongs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue