diff --git a/win32/_tfwopen.cpp b/win32/_tfwopen.cpp index 1accacb2..c9b75ea8 100644 --- a/win32/_tfwopen.cpp +++ b/win32/_tfwopen.cpp @@ -198,6 +198,18 @@ MS932ToWide::MS932ToWide(const char *ms932Chars) { MultiByteToWideChar(932,0,ms932Chars,-1,wideChars,requiredChars); } +AnsiToWide::AnsiToWide(const char *ansiChars) { + int requiredChars = MultiByteToWideChar(CP_ACP,0,ansiChars,-1,wideChars,0); + wideChars = new wchar_t[requiredChars]; + MultiByteToWideChar(CP_ACP,0,ansiChars,-1,wideChars,requiredChars); +} + +WideToAnsi::WideToAnsi(const wchar_t *wideChars) { + int requiredChars = WideCharToMultiByte(CP_ACP,0,wideChars,-1,ansiChars,0,NULL,NULL); + ansiChars = new char[requiredChars]; + WideCharToMultiByte(CP_ACP,0,wideChars,-1,ansiChars,requiredChars,NULL,NULL); +} + extern "C" FILE *_tfwopen(const char *filename, const char *mode ) { wchar_t mode_w[30]; lstrcpyn(mode_w,Utf8ToWide(mode),29); diff --git a/win32/_tfwopen.h b/win32/_tfwopen.h index c290cb5d..1f1fbb89 100644 --- a/win32/_tfwopen.h +++ b/win32/_tfwopen.h @@ -236,6 +236,24 @@ public: operator wchar_t *() { return wideChars; } }; +class AnsiToWide { +private: + wchar_t *wideChars; +public: + AnsiToWide(const char *ansiChars); + ~AnsiToWide() { delete [] wideChars; } + operator wchar_t *() { return wideChars; } +}; + +class WideToAnsi { +private: + char *ansiChars; +public: + WideToAnsi(const wchar_t *wideChars); + ~WideToAnsi() { delete [] ansiChars; } + operator char *() { return ansiChars; } +}; + namespace std { class u8nifstream: public std::ifstream { diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h index 415c9c3f..24fc1e3e 100644 --- a/win32/wsnes9x.h +++ b/win32/wsnes9x.h @@ -218,10 +218,14 @@ #define _tToChar WideToUtf8 #define _tFromChar Utf8ToWide #define _tFromMS932 MS932ToWide +#define _tToAnsi WideToAnsi +#define _tFromAnsi AnsiToWide #else #define _tToChar #define _tFromChar #define _tFromMS932 +#define _tToAnsi +#define _tFromAnsi #endif /****************************************************************************/