use new MultiByteToWideChar and WideCharToMultiByte implementation

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3824 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-12-11 16:10:28 +00:00
parent 7440f82655
commit 34db7b90f2
2 changed files with 10 additions and 99 deletions

View file

@ -122,34 +122,14 @@ void CResourceVersionInfo::SetProductVersion(int HighPart, int LowPart)
// Util function - must be freeded
WCHAR* StrToWstrAlloc(const char* istr, int codepage)
{
#ifdef _WIN32
int strSize = MultiByteToWideChar(codepage, 0, istr, -1, 0, 0);
WCHAR* wstr = new WCHAR[strSize];
MultiByteToWideChar(codepage, 0, istr, -1, wstr, strSize);
return wstr;
#else
WCHAR *wstr = NULL;
char cp[128] = "";
if (codepage != CP_ACP)
snprintf(cp, 128, "CP%d", codepage);
iconv_t cd = iconv_open("UCS-2", cp);
if (cd != (iconv_t) -1)
if (!MultiByteToWideChar(codepage, 0, istr, -1, wstr, strSize))
{
int len = strlen(istr);
char *in = (char *) istr;
wstr = new WCHAR[len + 1];
char *out = (char *) wstr;
size_t insize = len + 1;
size_t outsize = (len + 1) * sizeof(WCHAR);
if (__iconv_adaptor(iconv, cd, &in, &insize, &out, &outsize) == (size_t) -1)
{
delete [] wstr;
wstr = NULL;
}
iconv_close(cd);
delete [] wstr;
wstr = NULL;
}
return wstr;
#endif
}
int GetVersionHeader (LPSTR &p, WORD &wLength, WORD &wValueLength, WORD &wType)