Cleaning up unicode conversion

This commit is contained in:
kaetemi 2019-05-01 10:17:01 +08:00
parent 44124e5853
commit 1c422390e7
4 changed files with 15 additions and 5 deletions

View file

@ -54,7 +54,17 @@ struct HINSTANCE__;
typedef struct HINSTANCE__ *HINSTANCE; typedef struct HINSTANCE__ *HINSTANCE;
typedef char CHAR; typedef char CHAR;
typedef wchar_t WCHAR;
typedef CHAR *LPSTR; typedef CHAR *LPSTR;
typedef WCHAR *LPWSTR;
#if defined(UNICODE) || defined(_UNICODE)
typedef LPWSTR LPTSTR;
#else
typedef LPSTR LPTSTR;
#endif
#endif #endif
namespace NLNET namespace NLNET

View file

@ -1810,7 +1810,7 @@ emptyProc CDriverD3D::getWindowProc()
IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon) IDriver::TMessageBoxId CDriverD3D::systemMessageBox (const char* message, const char* title, TMessageBoxType type, TMessageBoxIcon icon)
{ {
switch (::MessageBoxW (_HWnd, utf8ToWide(message), utf8ToWide(title), ((type==retryCancelType)?MB_RETRYCANCEL: switch (::MessageBoxW(_HWnd, nlUtf8ToWide(message), nlUtf8ToWide(title), ((type == retryCancelType) ? MB_RETRYCANCEL :
(type==yesNoCancelType)?MB_YESNOCANCEL: (type==yesNoCancelType)?MB_YESNOCANCEL:
(type==okCancelType)?MB_OKCANCEL: (type==okCancelType)?MB_OKCANCEL:
(type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE: (type==abortRetryIgnoreType)?MB_ABORTRETRYIGNORE:

View file

@ -95,7 +95,7 @@ bool CXDPFileReader::init(const std::string &sFilename, sint32 nLowerBound, sint
{ {
// First open the file with a normal function // First open the file with a normal function
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
int fd = _wopen(utf8ToWide(sFilename), _O_BINARY | _O_RDONLY); int fd = _wopen(nlUtf8ToWide(sFilename), _O_BINARY | _O_RDONLY);
#else #else
int fd = open(sFilename.c_str(), O_RDONLY); int fd = open(sFilename.c_str(), O_RDONLY);
#endif #endif

View file

@ -88,7 +88,7 @@ static void setPermanentBanFileMarker(const std::string &path, bool on)
// simply touch a file // simply touch a file
COFile f(path); COFile f(path);
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
SetFileAttributesW(utf8ToWide(path), FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM); SetFileAttributesW(nlUtf8ToWide(path), FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM);
#endif #endif
} }
catch(const EStream &e) catch(const EStream &e)