Added !appendfile /CHARSET parameter, output is written using the new NOStream class
git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@6326 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
fe8e4a36bf
commit
9b35c900cb
10 changed files with 390 additions and 97 deletions
|
@ -211,6 +211,30 @@ int wsprintf(TCHAR *s, const TCHAR *format, ...) {
|
|||
return res;
|
||||
}
|
||||
|
||||
bool nsis_iconv_reallociconv(iconv_t CD, char**In, size_t*cbInLeft, char**Mem, size_t&cbConverted)
|
||||
{
|
||||
char *in, *heap = *Mem;
|
||||
UINT cbMem = 512;
|
||||
size_t inleft, outleft, icvret = (size_t) -1;
|
||||
for(;;)
|
||||
{
|
||||
in = *In, inleft = *cbInLeft, outleft = cbMem - sizeof(UINT32); // Leave room for \0
|
||||
char *p = (char*) realloc(heap, cbMem), *out = p;
|
||||
if (!p) break;
|
||||
heap = p, icvret = nsis_iconv_adaptor(iconv, CD, &in, &inleft, &out, &outleft);
|
||||
if ((size_t) -1 != icvret || E2BIG != errno) break;
|
||||
cbMem *= 4;
|
||||
}
|
||||
*In = in, *Mem = heap;
|
||||
cbConverted = cbMem - (outleft + sizeof(UINT32)), *cbInLeft = inleft;
|
||||
if ((size_t) -1 != icvret)
|
||||
{
|
||||
*((UINT32*)(&heap[cbConverted])) = 0;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void static create_code_page_string(TCHAR *buf, size_t len, UINT code_page) {
|
||||
switch(code_page)
|
||||
{
|
||||
|
@ -221,8 +245,11 @@ void static create_code_page_string(TCHAR *buf, size_t len, UINT code_page) {
|
|||
case CP_UTF8:
|
||||
_sntprintf(buf, len, _T("UTF-8"));
|
||||
return;
|
||||
case 1200: // UTF16LE
|
||||
case 1201: // UTF16BE
|
||||
_sntprintf(buf, len, _T("UTF-16%cE"), 1200==code_page ? _T('L') : _T('B'));
|
||||
return;
|
||||
}
|
||||
|
||||
_sntprintf(buf, len, _T("CP%d"), code_page);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue