diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 4cbdd93e..51d1aaef 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -48,6 +48,7 @@ add_library(appleii SHARED linux/windows/dsound.cpp linux/windows/guiddef.cpp linux/windows/dmusicc.cpp + linux/windows/winnls.cpp linux/data.cpp linux/benchmark.cpp diff --git a/source/linux/win.h b/source/linux/win.h index 5e11fc71..b4e002df 100644 --- a/source/linux/win.h +++ b/source/linux/win.h @@ -20,3 +20,4 @@ #include "linux/windows/mmreg.h" #include "linux/windows/mmsystem.h" #include "linux/windows/dmusicc.h" +#include "linux/windows/winnls.h" diff --git a/source/linux/windows/wincompat.h b/source/linux/windows/wincompat.h index c4e8b908..bbb7dc06 100644 --- a/source/linux/windows/wincompat.h +++ b/source/linux/windows/wincompat.h @@ -139,6 +139,7 @@ typedef short SHORT; typedef /*long*/int LONG; typedef SHORT *PSHORT; typedef LONG *PLONG; +typedef wchar_t WCHAR; #endif typedef LONG HRESULT; @@ -166,6 +167,8 @@ typedef LPSTR PTSTR, LPTSTR; typedef LPCSTR LPCTSTR; typedef LPSTR LP; +typedef WCHAR *LPWSTR; +typedef CONST WCHAR *LPCWSTR; #ifndef _TCHAR_DEFINED // TCHAR a typedef or a define? diff --git a/source/linux/windows/winnls.cpp b/source/linux/windows/winnls.cpp new file mode 100644 index 00000000..266e6cb6 --- /dev/null +++ b/source/linux/windows/winnls.cpp @@ -0,0 +1,26 @@ +#include "linux/windows/winnls.h" + +#include +#include + +// massive hack until I understand how it works! + +INT WINAPI MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, INT cbMultiByte, LPWSTR lpWideCharStr, INT cchWideChar) +{ +// int res = mbstowcs(lpWideCharStr, lpMultiByteStr, strlen(lpMultiByteStr)); + if (lpWideCharStr) + { + strcpy(reinterpret_cast(lpWideCharStr), lpMultiByteStr); + } + return strlen(lpMultiByteStr) + 1; // add NULL char at end +} + +INT WINAPI WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, INT cchWideChar, LPSTR lpMultiByteStr, INT cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar) +{ + if (lpMultiByteStr) + { + strcpy(lpMultiByteStr, reinterpret_cast(lpWideCharStr)); + } + // size_t res = wcstombs(lpMultiByteStr, lpWideCharStr, cbMultiByte); + return strlen((const char *)lpWideCharStr) + 1; +} diff --git a/source/linux/windows/winnls.h b/source/linux/windows/winnls.h new file mode 100644 index 00000000..acc90472 --- /dev/null +++ b/source/linux/windows/winnls.h @@ -0,0 +1,10 @@ +#pragma once + +#include "linux/windows/wincompat.h" + +#define CP_ACP 0 +#define CP_UTF8 65001 +#define MB_ERR_INVALID_CHARS 0x08 + +INT WINAPI MultiByteToWideChar(UINT,DWORD,LPCSTR,INT,LPWSTR,INT); +INT WINAPI WideCharToMultiByte(UINT,DWORD,LPCWSTR,INT,LPSTR,INT,LPCSTR,LPBOOL);