diff options
Diffstat (limited to 'Source/Core/DiscIO/Src/BannerLoader.cpp')
| -rw-r--r-- | Source/Core/DiscIO/Src/BannerLoader.cpp | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/Src/BannerLoader.cpp b/Source/Core/DiscIO/Src/BannerLoader.cpp index 60cee599b0..a45a286c4d 100644 --- a/Source/Core/DiscIO/Src/BannerLoader.cpp +++ b/Source/Core/DiscIO/Src/BannerLoader.cpp @@ -23,6 +23,11 @@ #include "VolumeCreator.h" #include "FileUtil.h" +// HyperIris: dunno if this suitable, may be need move. +#ifdef WIN32 +#include <Windows.h> +#endif + namespace DiscIO { bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* _src) @@ -89,6 +94,89 @@ bool IBannerLoader::CopyToStringAndCheck(std::string& _rDestination, const char* return(bResult); } +bool IBannerLoader::CopySJISToString( std::string& _rDestination, const char* _src ) +{ + bool returnCode = false; +#ifdef WIN32 + // HyperIris: because dolphin using "Use Multi-Byte Character Set", + // we must convert the SJIS chars to unicode then to our windows local by hand + u32 unicodeNameSize = MultiByteToWideChar(932, MB_PRECOMPOSED, + _src, strlen(_src), NULL, NULL); + if (unicodeNameSize > 0) + { + u16* pUnicodeStrBuffer = new u16[unicodeNameSize + 1]; + if (pUnicodeStrBuffer) + { + memset(pUnicodeStrBuffer, 0, (unicodeNameSize + 1) * sizeof(u16)); + if (MultiByteToWideChar(932, MB_PRECOMPOSED, + _src, strlen(_src), + (LPWSTR)pUnicodeStrBuffer, unicodeNameSize)) + { + u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0, + (LPCWSTR)pUnicodeStrBuffer, unicodeNameSize, + NULL, NULL, NULL, NULL); + if (ansiNameSize > 0) + { + char* pAnsiStrBuffer = new char[ansiNameSize + 1]; + if (pAnsiStrBuffer) + { + memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char)); + if (WideCharToMultiByte(CP_ACP, 0, + (LPCWSTR)pUnicodeStrBuffer, unicodeNameSize, + pAnsiStrBuffer, ansiNameSize, NULL, NULL)) + { + _rDestination = pAnsiStrBuffer; + returnCode = true; + } + delete pAnsiStrBuffer; + } + } + } + delete pUnicodeStrBuffer; + } + } +#else + // not implement other than windows + _rDestination = _src; + returnCode = true; +#endif + return returnCode; +} + +bool IBannerLoader::CopyUnicodeToString( std::string& _rDestination, const u16* _src ) +{ + bool returnCode = false; +#ifdef WIN32 + if (_src) + { + u32 ansiNameSize = WideCharToMultiByte(CP_ACP, 0, + (LPCWSTR)_src, wcslen((const wchar_t*)_src), + NULL, NULL, NULL, NULL); + if (ansiNameSize > 0) + { + char* pAnsiStrBuffer = new char[ansiNameSize + 1]; + if (pAnsiStrBuffer) + { + memset(pAnsiStrBuffer, 0, (ansiNameSize + 1) * sizeof(char)); + if (WideCharToMultiByte(CP_ACP, 0, + (LPCWSTR)_src, wcslen((const wchar_t*)_src), + pAnsiStrBuffer, ansiNameSize, NULL, NULL)) + { + _rDestination = pAnsiStrBuffer; + returnCode = true; + } + delete pAnsiStrBuffer; + } + } + } +#else + // not implement other than windows + _rDestination = _src; + returnCode = true; +#endif + return returnCode; +} + IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem) { |
