feat(launcher): Convert windows command line to UTF-8
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Successful in 1m46s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Ubuntu Cross to Win64 / Cross Compile with ming64 (1.4.0, ubuntu-latest) (push) Successful in 1m46s
				
			This commit is contained in:
		
							parent
							
								
									25006139f1
								
							
						
					
					
						commit
						dd76b924c0
					
				@ -404,9 +404,38 @@ static int Entry(int argc, char **argv) {
 | 
			
		||||
 | 
			
		||||
#ifdef _WIN32
 | 
			
		||||
#define WIN32_LEAN_AND_MEAN
 | 
			
		||||
#include <windows.h>
 | 
			
		||||
 | 
			
		||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pCmdLine, int nCmdShow) {
 | 
			
		||||
    _hInstance = hInstance;
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
    /* Convert to UTF-8 argv array */
 | 
			
		||||
    LPWSTR pWCmdLine = GetCommandLineW();
 | 
			
		||||
    int argc = 0;
 | 
			
		||||
    LPWSTR *pWArgv = CommandLineToArgvW(pWCmdLine, &argc);
 | 
			
		||||
    /* Determine total amount of memory needed */
 | 
			
		||||
    size_t mem_required = sizeof(char *) * argc; /* array of pointers */
 | 
			
		||||
    for (int i = 0; i < argc; ++i) {
 | 
			
		||||
        mem_required += (size_t)WideCharToMultiByte(CP_UTF8, WC_COMPOSITECHECK, pWArgv[i], -1, NULL, 0, NULL, NULL);
 | 
			
		||||
    }
 | 
			
		||||
    void *argv_mem = VirtualAlloc(NULL, mem_required, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
 | 
			
		||||
    char **argv = argv_mem;
 | 
			
		||||
    char *arg = (char *)(argv + argc);
 | 
			
		||||
    for (int i = 0; i < argc; ++i) {
 | 
			
		||||
        int len = WideCharToMultiByte(CP_UTF8, WC_COMPOSITECHECK, pWArgv[i], -1, NULL, 0, NULL, NULL);
 | 
			
		||||
        WideCharToMultiByte(CP_UTF8, WC_COMPOSITECHECK, pWArgv[i], -1, arg, len, NULL, NULL);
 | 
			
		||||
        argv[i] = arg;
 | 
			
		||||
        arg += len;
 | 
			
		||||
    }
 | 
			
		||||
    LocalFree(pWArgv);
 | 
			
		||||
 | 
			
		||||
    for (int i = 0; i < argc; ++i) {
 | 
			
		||||
        rtLog("LAUNCHER", "argv[%d]: %s", i, argv[i]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    int res = Entry(argc, argv);
 | 
			
		||||
    VirtualFree(argv_mem, 0, MEM_RELEASE);
 | 
			
		||||
    return res;
 | 
			
		||||
}
 | 
			
		||||
#else
 | 
			
		||||
int main(int argc, char **argv) {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user