Skip to content

[Windows] load image with filenames other than english #7435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 124 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
8185434
win
dimitre Mar 24, 2023
6c2b67c
up
dimitre Mar 26, 2023
7334eca
up
dimitre Mar 26, 2023
582d5b6
of::fs
dimitre Mar 26, 2023
7b60023
winwin
dimitre Mar 26, 2023
43c02a2
txt
dimitre Mar 26, 2023
0e5e9a2
txt
dimitre Mar 26, 2023
8013b73
empty
dimitre Mar 26, 2023
4d3ab8b
empty
dimitre Mar 26, 2023
2b0cd8c
more conversion
dimitre Mar 26, 2023
016d00b
more conversion
dimitre Mar 26, 2023
1d6bd8f
up
dimitre Mar 26, 2023
575ff37
up
dimitre Mar 26, 2023
8bf2584
fixing all ofImage path
dimitre Mar 26, 2023
1989b3b
fixing all ofImage path
dimitre Mar 26, 2023
b1b080e
fixing all ofImage path
dimitre Mar 26, 2023
c01b21b
fixing all ofImage path
dimitre Mar 26, 2023
f6838ce
fixing all ofImage path
dimitre Mar 26, 2023
b641599
fixing all ofImage path
dimitre Mar 26, 2023
c9fdee6
fixing all ofImage path
dimitre Mar 26, 2023
d66db75
fixing all ofImage path
dimitre Mar 26, 2023
a0653b4
Merge branch 'openframeworks:master' into win
dimitre Mar 26, 2023
bef9d88
up
dimitre Mar 26, 2023
7d89e96
wstring
dimitre Mar 26, 2023
108e9a4
up
dimitre Mar 26, 2023
fa5cb39
up
dimitre Mar 26, 2023
e4c8efa
<codecvt>
dimitre Mar 26, 2023
b67d52a
Merge branch 'master' into win
dimitre Apr 3, 2023
fa6879d
Merge branch 'master' into win
dimitre Apr 17, 2023
0b52d97
implicit wstring conversion
dimitre Apr 17, 2023
2bb0c2a
ofImage #ifdefs change and wstring removal
dimitre Apr 17, 2023
2f99775
ofLoadURL from string() to c_str() to keep encoding correct in dif. p…
dimitre Apr 17, 2023
2a00b51
test
dimitre Apr 17, 2023
5739a27
Merge branch 'openframeworks:master' into win
dimitre Apr 17, 2023
b40f6cc
filename.c_str()
dimitre Apr 17, 2023
72575d8
up
dimitre Apr 17, 2023
e6246ce
Merge branch 'openframeworks:master' into win
dimitre Apr 19, 2023
1f30785
Merge branch 'master' into win
dimitre Dec 1, 2023
f2e17e0
Merge branch 'openframeworks:master' into win
dimitre Dec 6, 2023
9db89aa
Merge branch 'master' into win
dimitre Dec 6, 2023
17f0e16
fix extension() without c_str
dimitre Dec 6, 2023
f51aafb
ofImage fix
dimitre Dec 6, 2023
16e34f7
ofImage fix
dimitre Dec 6, 2023
a86a930
revert ofFileUtils
dimitre Dec 6, 2023
f4d37dd
indent
dimitre Dec 6, 2023
1056168
remove duplicate code after automatic merge
dimitre Dec 6, 2023
0fba1d5
revert back ofLoadImage.string()
dimitre Dec 6, 2023
e3a6430
missing headers?
dimitre Dec 6, 2023
d961e2a
more changes
dimitre Dec 6, 2023
442e43b
more changes
dimitre Dec 6, 2023
ead9fc2
up
dimitre Dec 6, 2023
49f30dc
string empty fix
dimitre Dec 6, 2023
bcd8ec5
another test
dimitre Dec 6, 2023
1cd833f
another test
dimitre Dec 6, 2023
e0a0291
more simplification
dimitre Dec 6, 2023
2ec2a86
more test
dimitre Dec 6, 2023
900fe57
more test
dimitre Dec 6, 2023
e267f15
more test
dimitre Dec 6, 2023
0908a14
Merge branch 'openframeworks:master' into win
dimitre Dec 12, 2023
1ba85d6
Merge branch 'openframeworks:master' into win
dimitre Jan 7, 2024
7baa079
Merge branch 'openframeworks:master' into win
dimitre Feb 8, 2024
e31bdac
Merge branch 'openframeworks:master' into win
dimitre May 10, 2024
e5555d9
Merge branch 'openframeworks:master' into win
dimitre May 13, 2024
6200cc4
up test msys2
dimitre May 13, 2024
20f1214
more info
dimitre May 13, 2024
81b5b7b
pwd
dimitre May 13, 2024
df66718
pwd
dimitre May 13, 2024
6d4f82b
revert make files
dimitre May 13, 2024
5110bd3
Merge branch 'openframeworks:master' into win
dimitre May 19, 2024
7328ec2
fix conflicts
dimitre Jul 19, 2024
b1adc7b
wcscpy fix
dimitre Jul 19, 2024
ae6f180
alternative
dimitre Jul 19, 2024
a12bfc9
up
dimitre Jul 19, 2024
dad1a7e
submodules update
dimitre Jul 19, 2024
d8e4456
Merge branch 'openframeworks:master' into win
dimitre Jul 28, 2024
93dcb4e
up
dimitre Jul 28, 2024
9f84c8b
update
dimitre Sep 1, 2024
4cfabcb
Merge branch 'openframeworks:master' into win
dimitre Sep 13, 2024
e07ec1b
update
dimitre Sep 13, 2024
5fbc6d0
merge master
dimitre Sep 13, 2024
56e3b1f
fix conflicts
dimitre Sep 13, 2024
8084dc1
cleanup
dimitre Sep 13, 2024
6247654
Merge branch 'openframeworks:master' into win
dimitre Oct 20, 2024
9dc217c
cleanup, pg submodule update
dimitre Oct 20, 2024
09efdc2
updates win encoding
dimitre Oct 20, 2024
87b097f
windowTitleW
dimitre Oct 20, 2024
3ad9458
windowTitleW
dimitre Oct 20, 2024
6628744
Merge branch 'openframeworks:master' into win
dimitre Oct 20, 2024
69bf8f0
Merge branch 'openframeworks:master' into win
dimitre Oct 21, 2024
9d8d67f
ofSystemAlertDialog ok?
dimitre Oct 21, 2024
049fb8f
changes
dimitre Oct 21, 2024
d96f642
changes
dimitre Oct 21, 2024
6a7f88d
up
dimitre Oct 21, 2024
a3bf6be
up
dimitre Oct 21, 2024
c55b925
up
dimitre Oct 21, 2024
d120b5a
fix
dimitre Oct 21, 2024
aa04ca1
fix
dimitre Oct 21, 2024
7b2c29b
up
dimitre Oct 21, 2024
d0e8a6b
up
dimitre Oct 21, 2024
913cea5
update
dimitre Oct 21, 2024
84a72ca
updates
dimitre Oct 21, 2024
510bb6d
updates
dimitre Oct 21, 2024
9ff9345
updates
dimitre Oct 21, 2024
bad8dd1
updates
dimitre Oct 21, 2024
b4570b1
updates
dimitre Oct 21, 2024
1d256a0
updates
dimitre Oct 21, 2024
15bb60f
updates
dimitre Oct 21, 2024
8c2b569
updates
dimitre Oct 21, 2024
d965737
updates
dimitre Oct 21, 2024
6ea49dd
updates
dimitre Oct 21, 2024
3f07cb6
updates
dimitre Oct 21, 2024
0eb089e
updates
dimitre Oct 21, 2024
cde0d81
updates
dimitre Oct 21, 2024
33ebf5c
updates
dimitre Oct 21, 2024
eb76370
fix sizeof
dimitre Oct 21, 2024
4c0f10b
up
dimitre Oct 21, 2024
ca87183
toolset 142
dimitre Oct 21, 2024
6604038
update
dimitre Oct 21, 2024
6fa9da0
revert
dimitre Oct 21, 2024
c6621d3
revert
dimitre Oct 21, 2024
79f7636
up
dimitre Oct 21, 2024
afaa3ed
update
dimitre Oct 21, 2024
f09851e
err invalid chars
dimitre Oct 21, 2024
690027c
update
dimitre Oct 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/projectGenerator
14 changes: 7 additions & 7 deletions libs/openFrameworks/graphics/ofImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ static bool loadImage(ofPixels_<PixelType> & pix, const of::filesystem::path & _
if(uriParseUriA(&state, uriChar)!=URI_SUCCESS){
const int bytesNeeded = 8 + 3 * strlen(uriChar) + 1;
std::vector<char> absUri(bytesNeeded);
#ifdef TARGET_WIN32
uriWindowsFilenameToUriStringA(uriChar, absUri.data());
#else
uriUnixFilenameToUriStringA(uriChar, absUri.data());
#endif
#ifdef OF_OS_WINDOWS
uriWindowsFilenameToUriStringA(uriStr.c_str(), absUri.data());
#else
uriUnixFilenameToUriStringA(uriStr.c_str(), absUri.data());
#endif
if(uriParseUriA(&state, absUri.data())!=URI_SUCCESS){
ofLogError("ofImage") << "loadImage(): malformed uri when loading image from uri " << _fileName;
uriFreeUriMembersA(&uri);
Expand All @@ -239,7 +239,7 @@ static bool loadImage(ofPixels_<PixelType> & pix, const of::filesystem::path & _
fif = FreeImage_GetFileType(_fileName.c_str(), 0);
#endif
if(fif == FIF_UNKNOWN) {
// or guess via filename
// or guess via file extension
#ifdef OF_OS_WINDOWS
fif = FreeImage_GetFIFFromFilenameU(_fileName.c_str());
#else
Expand Down Expand Up @@ -599,7 +599,7 @@ static bool saveImage(const ofPixels_<PixelType> & _pix, ofBuffer & buffer, ofIm
but can also be retrieved by FreeImage_AcquireMemory that retrieves both the
length of the buffer, and the buffer memory address.
*/
#ifdef TARGET_WIN32
#ifdef OF_OS_WINDOWS
DWORD size_in_bytes = 0;
#else
std::uint32_t size_in_bytes = 0;
Expand Down
182 changes: 96 additions & 86 deletions libs/openFrameworks/utils/ofSystemUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,8 @@
#include <sstream>
#include <string>

std::string convertWideToNarrow( const wchar_t *s, char dfault = '?',
const std::locale& loc = std::locale() )
{
std::ostringstream stm;

while( *s != L'\0' ) {
stm << std::use_facet< std::ctype<wchar_t> >( loc ).narrow( *s++, dfault );
}
return stm.str();
}

std::wstring convertNarrowToWide( const std::string& as ){
// deal with trivial case of empty string
if( as.empty() ) return std::wstring();

// determine required length of new string
size_t reqLength = ::MultiByteToWideChar( CP_UTF8, 0, as.c_str(), (int)as.length(), 0, 0 );

// construct new string of required length
std::wstring ret( reqLength, L'\0' );

// convert old string to new string
::MultiByteToWideChar( CP_UTF8, 0, as.c_str(), (int)as.length(), &ret[0], (int)ret.length() );

// return new string ( compiler should optimize this away )
return ret;
}
#include <codecvt>
#include <iostream>

#endif

Expand Down Expand Up @@ -273,10 +248,12 @@ of::filesystem::path ofFileDialogResult::getPath(){
//------------------------------------------------------------------------------
void ofSystemAlertDialog(std::string errorMessage){
#ifdef TARGET_WIN32
// FIXME: Consider MultiByteToWideChar() and WideCharToMultiByte() / ConvertWideToUtf8
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
// we need to convert error message to a wide char message.
std::wstring errorMessageW{errorMessage.begin(),errorMessage.end()};
// std::wstring errorMessageW{errorMessage.begin(),errorMessage.end()};
// launch the alert:
MessageBoxW(nullptr, errorMessageW.c_str(), L"alert", MB_OK);
MessageBoxW(nullptr, converter.from_bytes(errorMessage).c_str(), L"alert", MB_OK);
#endif

#if defined(TARGET_OS_MAC) && !TARGET_OS_IPHONE && !TARGET_OS_WATCH && !TARGET_OS_TV && defined(__OBJC__)
Expand Down Expand Up @@ -320,11 +297,9 @@ static int CALLBACK loadDialogBrowseCallback(
LPARAM lParam,
LPARAM lpData
){
std::string defaultPath = *(std::string*)lpData;
if(defaultPath!="" && uMsg==BFFM_INITIALIZED){
wchar_t wideCharacterBuffer[MAX_PATH];
wcscpy(wideCharacterBuffer, ofToDataPath(defaultPath).c_str());
SendMessage(hwnd,BFFM_SETSELECTION,1,(LPARAM)wideCharacterBuffer);
std::wstring defaultPath { *(std::wstring*)lpData };
if(!defaultPath.empty() && uMsg==BFFM_INITIALIZED) {
SendMessage(hwnd,BFFM_SETSELECTION,1,(LPARAM)ofToDataPath(defaultPath).c_str());
}

return 0;
Expand Down Expand Up @@ -382,84 +357,109 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec
//------------------------------------------------------------------------------ windoze
//----------------------------------------------------------------------------------------
#ifdef TARGET_WIN32
std::wstring windowTitleW{windowTitle.begin(), windowTitle.end()};
std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;

if (bFolderSelection == false){

OPENFILENAME ofn;
HWND hwnd = WindowFromDC(wglGetCurrentDC());
std::wstring filename(MAX_PATH, L'\0');
// wchar_t szFileName[MAX_PATH];
// memset(szFileName, 0, sizeof(szFileName));

ZeroMemory(&ofn, sizeof(ofn));
OPENFILENAMEW ofn = { };
ofn.lStructSize = sizeof(ofn);
HWND hwnd = WindowFromDC(wglGetCurrentDC());
ofn.hwndOwner = hwnd;

//the file name and path
wchar_t szFileName[MAX_PATH];
memset(szFileName, 0, sizeof(szFileName));

//the dir, if specified
wchar_t szDir[MAX_PATH];

//the title if specified
wchar_t szTitle[MAX_PATH];
if(defaultPath!=""){
memset(szTitle, 0, sizeof(szTitle));
wcscpy(szTitle, converter.from_bytes(windowTitle).c_str());

if(!defaultPath.empty()){
wchar_t szDir[MAX_PATH];
wcscpy(szDir, ofToDataPath(defaultPath).c_str());
ofn.lpstrInitialDir = szDir;
}

if (windowTitle != "") {
wcscpy(szTitle, convertNarrowToWide(windowTitle).c_str());
ofn.lpstrTitle = szTitle;
} else {
ofn.lpstrTitle = nullptr;
}

ofn.lpstrFilter = L"All\0";
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = &filename[0];
ofn.nMaxFile = MAX_PATH + 1;
ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
ofn.lpstrDefExt = 0;
ofn.lpstrTitle = windowTitleW.c_str();

if(GetOpenFileName(&ofn)) {
results.filePath = convertWideToNarrow(szFileName);
ofn.lpstrTitle = szTitle;

// FIXME: issue 1 here
if(GetOpenFileNameW(&ofn)) {
// std::cout << *szFileName << endl;
// std::wstring fn = szFileName;
// of::filesystem::path outPath { szFileName };
// std::cout << "outPath " << outPath << std::endl;
// https://github.com/ePi5131/aulut/blob/137491c49400a590a55b85dd12faf046305f5b91/aulut/aulut.cpp#L165
std::cout << 0 << std::endl;
std::wcout << filename << std::endl;
std::cout << 1 << std::endl;
std::wstring name = filename;
std::cout << 2 << std::endl;

try {
std::cout << 3 << std::endl;
// results.filePath = filename;
// results.filePath = ConvertWideToUtf8(filename);
results.filePath = name;
std::cout << 4 << std::endl;

} catch (const std::system_error & e) {
std::cerr << e.what() << std::endl;
}
// std::cout << results.filePath << std::endl;
}
else {
std::cout << "error" << std::endl;

//this should throw an error on failure unless its just the user canceling out
//DWORD err = CommDlgExtendedError();
}

} else {

BROWSEINFOW bi;
BROWSEINFOW bi;
wchar_t wideCharacterBuffer[MAX_PATH];
wchar_t wideWindowTitle[MAX_PATH];
LPITEMIDLIST pidl;
LPMALLOC lpMalloc;

if (windowTitle != "") {
wcscpy(wideWindowTitle, convertNarrowToWide(windowTitle).c_str());
} else {
wcscpy(wideWindowTitle, L"Select Directory");
if (windowTitle.empty()) {
windowTitle = "Select Directory";
}
wchar_t wideWindowTitle[MAX_PATH];
wcscpy(wideWindowTitle, converter.from_bytes(windowTitle).c_str());




// Get a pointer to the shell memory allocator
if(SHGetMalloc(&lpMalloc) != S_OK){
//TODO: deal with some sort of error here?
}
bi.hwndOwner = nullptr;
bi.pidlRoot = nullptr;
bi.pszDisplayName = wideCharacterBuffer;
if (!defaultPath.empty()) {
wcscpy(wideCharacterBuffer, defaultPath.c_str());
bi.pszDisplayName = wideCharacterBuffer;
}
bi.lpszTitle = wideWindowTitle;
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS | BIF_USENEWUI;
bi.lpfn = &loadDialogBrowseCallback;
bi.lParam = (LPARAM) &defaultPath;
bi.lpszTitle = windowTitleW.c_str();
bi.lpszTitle = wideWindowTitle;

if( (pidl = SHBrowseForFolderW(&bi)) ){
// Copy the path directory to the buffer
if(SHGetPathFromIDListW(pidl,wideCharacterBuffer)){
results.filePath = convertWideToNarrow(wideCharacterBuffer);
wchar_t pathResult[MAX_PATH];
// char16_t pathResult[MAX_PATH];

if(SHGetPathFromIDListW(pidl, pathResult)){
results.filePath = pathResult;
}
lpMalloc->Free(pidl);
}
Expand Down Expand Up @@ -493,7 +493,7 @@ ofFileDialogResult ofSystemLoadDialog(std::string windowTitle, bool bFolderSelec

if( !results.filePath.empty() ){
results.bSuccess = true;
results.fileName = ofFilePath::getFileName(results.filePath);
results.fileName = results.filePath.filename();
}

return results;
Expand Down Expand Up @@ -524,40 +524,42 @@ ofFileDialogResult ofSystemSaveDialog(std::string defaultName, std::string messa
}
}
#endif
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------ windoze
//----------------------------------------------------------------------------------------
#ifdef TARGET_WIN32


wchar_t fileName[MAX_PATH] = L"";
OPENFILENAMEW ofn;
memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
// wchar_t pathBuffer[MAX_PATH] = L"";
wchar_t pathBuffer[MAX_PATH] = { 0 };
HWND hwnd = WindowFromDC(wglGetCurrentDC());

OPENFILENAMEW ofn = { } ;

ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = hwnd;
ofn.hInstance = GetModuleHandle(0);
ofn.nMaxFileTitle = 31;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFile = pathBuffer;
ofn.nMaxFile = MAX_PATH + 1;
ofn.lpstrFilter = L"All Files (*.*)\0*.*\0";
ofn.lpstrDefExt = L""; // we could do .rxml here?
ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
ofn.lpstrTitle = L"Select Output File";


if (GetSaveFileNameW(&ofn)){
results.filePath = convertWideToNarrow(fileName);
if (wcsnlen_s(pathBuffer, std::size(pathBuffer)) > 0) {
std::wstring fn = pathBuffer;
results.filePath = fn;
} else {
std::cout << "wrong wcsnlen_s size" << std::endl;
}
// results.filePath = fileName;
}

#endif
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------


//----------------------------------------------------------------------------------------
//------------------------------------------------------------------------------ linux
Expand All @@ -574,7 +576,7 @@ ofFileDialogResult ofSystemSaveDialog(std::string defaultName, std::string messa

if( !results.filePath.empty() ){
results.bSuccess = true;
results.fileName = ofFilePath::getFileName(results.filePath);
results.fileName = results.filePath.filename();
}

return results;
Expand Down Expand Up @@ -645,6 +647,10 @@ std::string ofSystemTextBoxDialog(std::string question, std::string text){
// we need to convert error message to a wide char message.
// first, figure out the length and allocate a wchar_t at that length + 1 (the +1 is for a terminating character)

std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;
// std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>> converter;


WNDCLASSEX wc;
MSG Msg;

Expand Down Expand Up @@ -679,7 +685,7 @@ std::string ofSystemTextBoxDialog(std::string question, std::string text){

HWND dialog = CreateWindowEx(WS_EX_DLGMODALFRAME,
g_szClassName,
convertNarrowToWide(question).c_str(),
converter.from_bytes(question).c_str(),
WS_POPUP | WS_CAPTION | DS_MODALFRAME | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 140,
WindowFromDC(wglGetCurrentDC()), nullptr, GetModuleHandle(0),nullptr);
Expand All @@ -694,11 +700,15 @@ std::string ofSystemTextBoxDialog(std::string question, std::string text){
}

EnableWindow(WindowFromDC(wglGetCurrentDC()), FALSE);
HWND hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT\0", convertNarrowToWide(text).c_str(),



HWND hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT\0", converter.from_bytes(text).c_str(),
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
10, 10, 210, 40, dialog, (HMENU)101, GetModuleHandle(nullptr), nullptr);



HWND okButton = CreateWindowEx(WS_EX_CLIENTEDGE, L"BUTTON\0", L"OK\0",
WS_CHILD | WS_VISIBLE | WS_TABSTOP,
10, 60, 60, 30, dialog, (HMENU)IDOK, GetModuleHandle(nullptr), nullptr);
Expand Down
16 changes: 16 additions & 0 deletions libs/openFrameworks/utils/ofSystemUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ ofFileDialogResult ofSystemSaveDialog(std::string defaultName, std::string messa
/// \param question descriptive text for the text entry, ie. "What's your favorite color?"
/// \param text optional default text entry string, ie. "blue"
std::string ofSystemTextBoxDialog(std::string question, std::string text="");

#ifdef TARGET_WIN32
std::string ConvertWideToUtf8(const std::wstring & wstr) {
int count = WideCharToMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, wstr.c_str(), wstr.length(), NULL, 0, NULL, NULL);
std::string str(count, 0);
WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), -1, &str[0], count, NULL, NULL);
return str;
}

std::wstring ConvertUtf8ToWide(const std::string & str) {
int count = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, str.c_str(), str.length(), NULL, 0);
std::wstring wstr(count, 0);
MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &wstr[0], count);
return wstr;
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' or '$(Configuration)|$(Platform)'=='Debug|ARM64' or '$(Configuration)|$(Platform)'=='Debug|ARM64EC'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' or '$(Configuration)|$(Platform)'=='Release|ARM64' or '$(Configuration)|$(Platform)'=='Release|ARM64EC'" Label="PropertySheets">
Expand Down