diff --git a/Contrib/Inetc/inetc.cpp b/Contrib/Inetc/inetc.cpp index 461267c..a9ae026 100644 --- a/Contrib/Inetc/inetc.cpp +++ b/Contrib/Inetc/inetc.cpp @@ -134,6 +134,8 @@ * Nadahar * Sep 21, 2018 - 1.0.5.5 * Created /NOSSL option that prevents redirects to HTTPS (which breaks Windows XP) +* Sep 24, 2018 - 1.0.5.6 - anders_k +* /tostackconv supports UTF-8 and UTF-16LE BOM sniffing and conversion. *******************************************************/ @@ -432,7 +434,10 @@ void fileTransfer(HANDLE localFile, if(szToStack) { for (DWORD i = 0; cntToStack < g_stringsize && i < rslt; i++, cntToStack++) - *(szToStack + cntToStack) = data_buf[i]; + if (convToStack) + *((BYTE*)szToStack + cntToStack) = data_buf[i]; // Bytes + else + *(szToStack + cntToStack) = data_buf[i]; // ? to TCHARs } else if(!WriteFile(localFile, data_buf, rslt, &bytesDone, NULL) || rslt != bytesDone) @@ -1008,7 +1013,7 @@ DWORD __stdcall inetTransfer(void *hw) if(szToStack) { for (DWORD i = 0; cntToStack < g_stringsize && i < rslt; i++, cntToStack++) - *(szToStack + cntToStack) = hdr[i]; + *(szToStack + cntToStack) = hdr[i]; // ASCII to TCHAR } else { @@ -1456,12 +1461,15 @@ INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) return false; case WM_PAINT: // child dialog redraw problem. return false is important - RedrawWindow(GetDlgItem(hDlg, IDC_STATIC1), NULL, NULL, RDW_INVALIDATE); - RedrawWindow(GetDlgItem(hDlg, IDCANCEL), NULL, NULL, RDW_INVALIDATE); - RedrawWindow(GetDlgItem(hDlg, IDC_PROGRESS1), NULL, NULL, RDW_INVALIDATE); - UpdateWindow(GetDlgItem(hDlg, IDC_STATIC1)); - UpdateWindow(GetDlgItem(hDlg, IDCANCEL)); - UpdateWindow(GetDlgItem(hDlg, IDC_PROGRESS1)); + { + HWND hS1 = GetDlgItem(hDlg, IDC_STATIC1), hC = GetDlgItem(hDlg, IDCANCEL), hP1 = GetDlgItem(hDlg, IDC_PROGRESS1); + RedrawWindow(hS1, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(hC, NULL, NULL, RDW_INVALIDATE); + RedrawWindow(hP1, NULL, NULL, RDW_INVALIDATE); + UpdateWindow(hS1); + UpdateWindow(hC); + UpdateWindow(hP1); + } return false; case WM_TIMER: if(!silent && IsWindow(hDlg)) @@ -1869,13 +1877,20 @@ void __declspec(dllexport) __cdecl get(HWND hwndParent, if(cntToStack > 0 && convToStack) { #ifdef UNICODE - int required = MultiByteToWideChar(CP_ACP, 0, (CHAR*)szToStack, string_size * sizeof(TCHAR), NULL, 0); + int cp = CP_ACP; + if (0xef == ((BYTE*)szToStack)[0] && 0xbb == ((BYTE*)szToStack)[1] && 0xbf == ((BYTE*)szToStack)[2]) cp = 65001; // CP_UTF8 + if (0xff == ((BYTE*)szToStack)[0] && 0xfe == ((BYTE*)szToStack)[1]) + { + cp = 1200; // UTF-16LE + pushstring((LPWSTR)szToStack); + } + int required = (cp == 1200) ? 0 : MultiByteToWideChar(cp, 0, (CHAR*)szToStack, string_size * sizeof(TCHAR), NULL, 0); if(required > 0) { WCHAR* pszToStackNew = (WCHAR*)LocalAlloc(LPTR, sizeof(WCHAR) * (required + 1)); if(pszToStackNew) { - if(MultiByteToWideChar(CP_ACP, 0, (CHAR*)szToStack, string_size * sizeof(TCHAR), pszToStackNew, required) > 0) + if(MultiByteToWideChar(cp, 0, (CHAR*)szToStack, string_size * sizeof(TCHAR), pszToStackNew, required) > 0) pushstring(pszToStackNew); LocalFree(pszToStackNew); } diff --git a/Contrib/Inetc/inetc.rc b/Contrib/Inetc/inetc.rc index 7a645b0..c58fcbb 100644 --- a/Contrib/Inetc/inetc.rc +++ b/Contrib/Inetc/inetc.rc @@ -186,8 +186,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,5,5 - PRODUCTVERSION 1,0,5,5 + FILEVERSION 1,0,5,6 + PRODUCTVERSION 1,0,5,6 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -203,12 +203,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "inetc NSIS plug-in" - VALUE "FileVersion", "1.0.5.5" + VALUE "FileVersion", "1.0.5.6" VALUE "InternalName", "inetc.dll" VALUE "LegalCopyright", "Copyright © Takhir Bedertdinov" VALUE "OriginalFilename", "inetc.dll" VALUE "ProductName", "inetc NSIS plug-in" - VALUE "ProductVersion", "1.0.5.5" + VALUE "ProductVersion", "1.0.5.6" END END BLOCK "VarFileInfo" diff --git a/README.md b/README.md index f123681..d12642f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Changes in this fork are: * **1.0.5.3** - Added options `/TEXTCOLOR "RRGGBB"` and `/BGCOLOR "RRGGBB"` * **1.0.5.4** - Created a 4th download dialog `/MODERNPOPUP` * **1.0.5.5** - Created option `/NOSSL` which prevents redirects from HTTP to HTTPS +* **1.0.5.6** - Applied changes from upstream `1.0.5.3`: `/tostackconv` supports UTF-8 and UTF-16LE BOM sniffing and conversion. Nadahar