mirror of https://github.com/snes9xgit/snes9x.git
win32: add AnsiToWide/WideToAnsi functions. This change is for Lua (non-Unicode DLL) and external modules (Lua-GD, for instance).
This commit is contained in:
parent
6fb8ae96b1
commit
1e2dd85321
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
||||
/****************************************************************************/
|
||||
|
|
Loading…
Reference in New Issue