Basic UTF-8 support in ansi build so it can read UTF-8 .nlf files and LangStrings
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6196 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
359ad0a055
commit
ef8a83bd41
10 changed files with 227 additions and 5 deletions
|
@ -200,8 +200,15 @@ inline size_t nsis_iconv_adaptor
|
|||
}
|
||||
|
||||
void static create_code_page_string(TCHAR *buf, size_t len, UINT code_page) {
|
||||
if (code_page == CP_ACP)
|
||||
switch(code_page)
|
||||
{
|
||||
case CP_ACP:
|
||||
code_page = 1252;
|
||||
break;
|
||||
case CP_UTF8:
|
||||
_sntprintf(buf, len, _T("UTF-8"));
|
||||
return;
|
||||
}
|
||||
|
||||
_sntprintf(buf, len, _T("CP%d"), code_page);
|
||||
}
|
||||
|
@ -209,7 +216,7 @@ void static create_code_page_string(TCHAR *buf, size_t len, UINT code_page) {
|
|||
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
|
||||
int cchWideChar, LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar,
|
||||
LPBOOL lpUsedDefaultChar) {
|
||||
static char buffer[4096];
|
||||
static char buffer[4096]; // BUGBUG: Should this be 4*NSIS_MAX_STRLEN for large string build?
|
||||
|
||||
char cp[128];
|
||||
create_code_page_string(cp, sizeof(cp), CodePage);
|
||||
|
@ -245,7 +252,7 @@ int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr,
|
|||
|
||||
int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
|
||||
int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar) {
|
||||
static WCHAR buffer[4096];
|
||||
static WCHAR buffer[4096]; // BUGBUG: Should this be 4*NSIS_MAX_STRLEN for large string build?
|
||||
|
||||
char cp[128];
|
||||
create_code_page_string(cp, sizeof(cp), CodePage);
|
||||
|
@ -900,3 +907,10 @@ bool GetDLLVersion(const tstring& filepath, DWORD& high, DWORD& low)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Platform_SupportsUTF8Conversion()
|
||||
{
|
||||
static unsigned char cached = -1;
|
||||
if (-1 == cached) cached = !!IsValidCodePage(CP_UTF8);
|
||||
return cached != 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue