win32: Unicode - fix Custom ROM dialog to show half-width katakana

This commit is contained in:
gocha 2012-07-22 14:57:35 +02:00 committed by OV2
parent e4bf711227
commit 5d6d3af4a9
4 changed files with 21 additions and 4 deletions

View File

@ -192,6 +192,12 @@ WideToUtf8::WideToUtf8(const wchar_t *wideChars) {
WideCharToMultiByte(CP_UTF8,0,wideChars,-1,utf8Chars,requiredChars,NULL,NULL);
}
MS932ToWide::MS932ToWide(const char *ms932Chars) {
int requiredChars = MultiByteToWideChar(932,0,ms932Chars,-1,wideChars,0);
wideChars = new wchar_t[requiredChars];
MultiByteToWideChar(932,0,ms932Chars,-1,wideChars,requiredChars);
}
extern "C" FILE *_tfwopen(const char *filename, const char *mode ) {
wchar_t mode_w[30];
lstrcpyn(mode_w,Utf8ToWide(mode),29);

View File

@ -215,6 +215,15 @@ public:
operator char *() { return utf8Chars; }
};
class MS932ToWide {
private:
wchar_t *wideChars;
public:
MS932ToWide(const char *ms932Chars);
~MS932ToWide() { delete [] wideChars; }
operator wchar_t *() { return wideChars; }
};
namespace std {
class u8nifstream: public std::ifstream
{

View File

@ -5245,7 +5245,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
if (InfoScore((char *)HeaderBuffer) > 1)
{
EHi = true;
_tcsncpy(namebuffer, _tFromChar((char *)HeaderBuffer), 21);
_tcsncpy(namebuffer, _tFromMS932((char *)HeaderBuffer), 21);
}
}
@ -5263,7 +5263,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
ROMFile.read(HiHead, INFO_LEN);
int HiScore = InfoScore(HiHead);
_tcsncpy(namebuffer, _tFromChar(LoScore > HiScore ? LoHead : HiHead), 21);
_tcsncpy(namebuffer, _tFromMS932(LoScore > HiScore ? LoHead : HiHead), 21);
if (filestats.st_size - HeaderSize >= 0x20000)
{
@ -5273,7 +5273,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
if (IntLScore > LoScore && IntLScore > HiScore)
{
_tcsncpy(namebuffer, _tFromChar(LoHead), 21);
_tcsncpy(namebuffer, _tFromMS932(LoHead), 21);
}
}
}
@ -5282,7 +5282,7 @@ void rominfo(const TCHAR *filename, TCHAR *namebuffer, TCHAR *sizebuffer)
char buf[21];
ROMFile.seekg(0x7FC0 + HeaderSize, ios::beg);
ROMFile.read(buf, 21);
_tcsncpy(namebuffer,_tFromChar(buf),21);
_tcsncpy(namebuffer,_tFromMS932(buf),21);
}
}
ROMFile.close();

View File

@ -216,9 +216,11 @@
#ifdef UNICODE
#define _tToChar WideToUtf8
#define _tFromChar Utf8ToWide
#define _tFromMS932 MS932ToWide
#else
#define _tToChar
#define _tFromChar
#define _tFromMS932
#endif
/****************************************************************************/