winport - fix bug where desmume would create working directory using some wrong locale encoding and produce a Pok魯n directory instead of using the Pokémon that was already there (fixes #791)
This commit is contained in:
parent
9515af82b2
commit
4a53a30b91
|
@ -87,7 +87,7 @@ void GetINIPath()
|
|||
}
|
||||
|
||||
FCEUD_MakePathDirs(IniName);
|
||||
wcscpy(IniNameW,mbstowcs(IniName).c_str()); //careful to use locale C-style mbstowcs to get IniName (which is with locale encoding) to unicode
|
||||
wcscpy(IniNameW,mbstowcs_locale(IniName).c_str());
|
||||
|
||||
//write BOM to get unicode
|
||||
FILE* test = fopen(IniName,"rb");
|
||||
|
|
|
@ -170,7 +170,7 @@ void createDirectoryRecursively(std::wstring path)
|
|||
|
||||
void FCEUD_MakePathDirs(const char *fname)
|
||||
{
|
||||
createDirectoryRecursively(mbstowcs(fname));
|
||||
createDirectoryRecursively(mbstowcs_locale(fname));
|
||||
}
|
||||
#endif
|
||||
//------------------------------
|
||||
|
|
|
@ -284,6 +284,19 @@ std::string mass_replace(const std::string &source, const std::string &victim, c
|
|||
return answer;
|
||||
}
|
||||
|
||||
std::wstring mbstowcs_locale(std::string str)
|
||||
{
|
||||
#ifdef HOST_WINDOWS
|
||||
int plenty = str.size()*4+1;
|
||||
wchar_t *wgarbage = new wchar_t[plenty];
|
||||
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, str.data(), -1, wgarbage, plenty);
|
||||
std::wstring ret = wgarbage;
|
||||
delete[] wgarbage;
|
||||
return ret;
|
||||
#endif
|
||||
return mbstowcs(str);
|
||||
}
|
||||
|
||||
//convert a std::string to std::wstring
|
||||
std::wstring mbstowcs(std::string str)
|
||||
{
|
||||
|
|
|
@ -107,5 +107,7 @@ std::string mass_replace(const std::string &source, const std::string &victim, c
|
|||
std::wstring mbstowcs(std::string str);
|
||||
std::string wcstombs(std::wstring str);
|
||||
|
||||
std::wstring mbstowcs_locale(std::string str);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue