2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 17:04:55 +00:00

char16_t formatting support

This commit is contained in:
Jack Andersen
2017-01-23 21:40:09 -10:00
parent 80b2223e88
commit b8abd466dd
4 changed files with 56 additions and 1 deletions

View File

@@ -65,6 +65,20 @@ std::wstring WideFormat(const wchar_t* format, ...)
return std::wstring(resultBuf, printSz);
}
std::u16string Char16Format(const wchar_t* format, ...)
{
wchar_t resultBuf[FORMAT_BUF_SZ];
va_list va;
va_start(va, format);
int printSz = vswprintf(resultBuf, FORMAT_BUF_SZ, format, va);
va_end(va);
std::u16string res;
res.reserve(printSz);
for (size_t i=0 ; i<printSz ; ++i)
res.push_back(resultBuf[i]);
return res;
}
void SanitizePath(std::string& path)
{
if (path.empty())