diff --git a/src/osd/modules/file/winfile.cpp b/src/osd/modules/file/winfile.cpp index 1f85fc15645..62f5681e697 100644 --- a/src/osd/modules/file/winfile.cpp +++ b/src/osd/modules/file/winfile.cpp @@ -207,11 +207,8 @@ osd_file::error osd_file::open(std::string const &orig_path, UINT32 openflags, p // create the path if necessary if ((ERROR_PATH_NOT_FOUND == err) && (openflags & OPEN_FLAG_CREATE) && (openflags & OPEN_FLAG_CREATE_PATHS)) { - // the code below assumes these are the same - assert(std::string::npos == std::wstring::npos); - auto pathsep = t_path.rfind('\\'); - if (pathsep != std::string::npos) + if (pathsep != decltype(t_path)::npos) { // create the path up to the file t_path[pathsep] = 0; diff --git a/src/osd/strconv.cpp b/src/osd/strconv.cpp index 3919dddbf18..49a70f52684 100644 --- a/src/osd/strconv.cpp +++ b/src/osd/strconv.cpp @@ -25,9 +25,9 @@ std::string &astring_from_utf8(std::string &dst, const char *s) std::basic_string wstring = wstring_from_utf8(s); // convert UTF-16 to "ANSI code page" string - int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, nullptr, 0, nullptr, nullptr); - dst.resize(char_count - 1); - WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size() + 1, &dst[0], char_count - 1, nullptr, nullptr); + int char_count = WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), nullptr, 0, nullptr, nullptr); + dst.resize(char_count); + WideCharToMultiByte(CP_ACP, 0, wstring.c_str(), wstring.size(), &dst[0], char_count, nullptr, nullptr); return dst; }