Unicode port: Turn console & output logs to UTF-8. Adapted MakensisW for UTF-8
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6083 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
b8f6c16fcd
commit
743ad095f5
6 changed files with 30 additions and 19 deletions
|
@ -30,6 +30,12 @@
|
|||
#include "toolbar.h"
|
||||
#include "update.h"
|
||||
|
||||
#ifdef _countof
|
||||
#define COUNTOF _countof
|
||||
#else
|
||||
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
NSCRIPTDATA g_sdata;
|
||||
NRESIZEDATA g_resize;
|
||||
NFINDREPLACE g_find;
|
||||
|
@ -740,7 +746,7 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
PostMessage(g_sdata.hwnd,WM_MAKENSIS_PROCESSCOMPLETE,0,0);
|
||||
return 1;
|
||||
}
|
||||
TCHAR szBuf[1024];
|
||||
char szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
DWORD dwExit = !STILL_ACTIVE;
|
||||
while (dwExit == STILL_ACTIVE || dwRead) {
|
||||
|
@ -748,7 +754,13 @@ DWORD WINAPI MakeNSISProc(LPVOID p) {
|
|||
if (dwRead) {
|
||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-sizeof(TCHAR), &dwRead, NULL);
|
||||
szBuf[dwRead] = 0;
|
||||
#ifdef _UNICODE
|
||||
TCHAR wideBuf[1024];
|
||||
MultiByteToWideChar(CP_UTF8,0,szBuf,-1,wideBuf,COUNTOF(wideBuf));
|
||||
LogMessage(g_sdata.hwnd, wideBuf);
|
||||
#else
|
||||
LogMessage(g_sdata.hwnd, szBuf);
|
||||
#endif
|
||||
}
|
||||
else Sleep(TIMEOUT);
|
||||
GetExitCodeProcess(pi.hProcess, &dwExit);
|
||||
|
|
|
@ -172,7 +172,7 @@ typedef struct NSISScriptData {
|
|||
TCHAR *output_exe;
|
||||
TCHAR *input_script;
|
||||
TCHAR *branding;
|
||||
TCHAR *brandingv;
|
||||
char *brandingv;
|
||||
TCHAR **symbols;
|
||||
int retcode;
|
||||
BOOL userSelectCompressor;
|
||||
|
|
|
@ -55,7 +55,6 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
|||
char url[300];
|
||||
BOOL error = FALSE;
|
||||
static char pbuf[8192];
|
||||
static char ansiBuf[1024];
|
||||
char *p=NULL;
|
||||
*response = 0;
|
||||
|
||||
|
@ -76,13 +75,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
|||
|
||||
JNL_HTTPGet *get = new JNL_HTTPGet(g_dns,8192,(p&&p[0])?p:NULL);;
|
||||
lstrcpyA(url,NSIS_UPDATE);
|
||||
|
||||
#ifdef _UNICODE
|
||||
WideCharToMultiByte(CP_ACP, 0, g_sdata.brandingv, -1, ansiBuf, sizeof(ansiBuf), NULL, NULL);
|
||||
lstrcatA(url,ansiBuf);
|
||||
#else
|
||||
lstrcatA(url,g_sdata.brandingv);
|
||||
#endif
|
||||
|
||||
lstrcpyA(response,"");
|
||||
get->addheader("User-Agent: MakeNSISw (jnetlib)");
|
||||
|
@ -139,7 +132,7 @@ DWORD CALLBACK UpdateThread(LPVOID v) {
|
|||
void Update() {
|
||||
DWORD dwThreadId;
|
||||
|
||||
if (_tcsstr(g_sdata.brandingv,_T("cvs")))
|
||||
if (strstr(g_sdata.brandingv,"cvs"))
|
||||
{
|
||||
MessageBox(g_sdata.hwnd,_T("Cannot check for new version of nightly builds. To update, download a new nightly build."),_T("NSIS Update"),MB_OK|MB_ICONSTOP);
|
||||
return;
|
||||
|
|
|
@ -603,18 +603,19 @@ int InitBranding() {
|
|||
CloseHandle(read_stdout);
|
||||
return 0;
|
||||
}
|
||||
TCHAR szBuf[1024];
|
||||
char szBuf[1024];
|
||||
DWORD dwRead = 1;
|
||||
if (WaitForSingleObject(pi.hProcess,10000)!=WAIT_OBJECT_0) {
|
||||
return 0;
|
||||
}
|
||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-sizeof(TCHAR), &dwRead, NULL);
|
||||
szBuf[dwRead/sizeof(TCHAR)] = 0;
|
||||
if (lstrlen(szBuf)==0) return 0;
|
||||
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+6)*sizeof(TCHAR));
|
||||
wsprintf(g_sdata.branding,_T("NSIS %s"),szBuf);
|
||||
g_sdata.brandingv = (TCHAR *)GlobalAlloc(GPTR,(lstrlen(szBuf)+1)*sizeof(TCHAR));
|
||||
lstrcpy(g_sdata.brandingv,szBuf);
|
||||
ReadFile(read_stdout, szBuf, sizeof(szBuf)-1, &dwRead, NULL);
|
||||
szBuf[dwRead] = 0;
|
||||
int len = lstrlenA(szBuf);
|
||||
if (len==0) return 0;
|
||||
g_sdata.branding = (TCHAR *)GlobalAlloc(GPTR,(len+6)*sizeof(TCHAR));
|
||||
wsprintf(g_sdata.branding,_T("NSIS %hs"),szBuf);
|
||||
g_sdata.brandingv = (char *)GlobalAlloc(GPTR,len+1);
|
||||
lstrcpyA(g_sdata.brandingv,szBuf);
|
||||
GlobalFree(s);
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
#include "util.h"
|
||||
|
||||
#include <nsis-version.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -268,6 +270,9 @@ int _tmain(int argc, TCHAR **argv)
|
|||
int no_logo=0;
|
||||
int in_files=0;
|
||||
|
||||
#ifdef _UNICODE
|
||||
_setmode(_fileno(stdout), _O_U8TEXT); // set console output as UTF-8
|
||||
#endif
|
||||
try
|
||||
{
|
||||
build.initialize(argv[0]);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
FILE* FileOpenUnicodeText(const TCHAR* file, const TCHAR* mode)
|
||||
{
|
||||
extern FILE *g_output;
|
||||
CValidateUnicode::FILE_TYPE ftype = CValidateUnicode::UTF_16LE;
|
||||
CValidateUnicode::FILE_TYPE ftype = CValidateUnicode::UTF_8; // default file format is UTF-8
|
||||
|
||||
// If we are reading an existing file, check to see what type of file it
|
||||
// is first.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue