swapped unpacking order of to and from and caller parameters
removed null terminator adding at end
changed call from stdcall to cdecl
This commit was merged in pull request #387.
This commit is contained in:
@@ -27,7 +27,7 @@ dword ChangeCharset(dword from_chs, to_chs, conv_buf)
|
||||
{
|
||||
dword cd, in_len, out_len, new_buf;
|
||||
|
||||
iconv_open stdcall (from_chs*10+#charsets, to_chs*10+#charsets);
|
||||
iconv_open cdecl (to_chs*10+#charsets, from_chs*10+#charsets);
|
||||
if (EAX==-1) {
|
||||
debugln("iconv: unsupported charset");
|
||||
return 0;
|
||||
@@ -37,7 +37,7 @@ dword ChangeCharset(dword from_chs, to_chs, conv_buf)
|
||||
in_len = strlen(conv_buf)+1;
|
||||
out_len = in_len * 2;
|
||||
new_buf = mem_Alloc(out_len);
|
||||
iconv stdcall (cd, #conv_buf, #in_len, #new_buf, #out_len);
|
||||
iconv cdecl (cd, #conv_buf, #in_len, #new_buf, #out_len);
|
||||
if (EAX!=0)
|
||||
{
|
||||
cd = EAX;
|
||||
|
||||
@@ -64,8 +64,8 @@ size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
|
||||
char *str;
|
||||
str=*outbuf;
|
||||
|
||||
from=cd>>16;
|
||||
to=cd&0xFFFF;
|
||||
to=cd>>16;
|
||||
from=cd&0xFFFF;
|
||||
|
||||
switch (from)
|
||||
{
|
||||
@@ -92,7 +92,7 @@ size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
|
||||
count1=0;
|
||||
count2=0;
|
||||
|
||||
while ( *inbytesleft>0 && *outbytesleft>1)
|
||||
while (*inbytesleft>0 && *outbytesleft>1)
|
||||
{
|
||||
n=1;
|
||||
|
||||
@@ -116,7 +116,6 @@ size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf,
|
||||
count1+=converted;
|
||||
count2+=written;
|
||||
}
|
||||
*(str+count2)='\0';
|
||||
|
||||
if (*inbytesleft>0 && *outbytesleft==0) return -12;
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user