Lines 19-24
Link Here
|
19 |
*/ |
19 |
*/ |
20 |
|
20 |
|
21 |
#include <time.h> |
21 |
#include <time.h> |
|
|
22 |
#include <errno.h> |
23 |
#include <iconv.h> |
24 |
#include <langinfo.h> |
22 |
#include "rdesktop.h" |
25 |
#include "rdesktop.h" |
23 |
|
26 |
|
24 |
extern uint16 g_mcs_userid; |
27 |
extern uint16 g_mcs_userid; |
Lines 119-135
Link Here
|
119 |
void |
122 |
void |
120 |
rdp_out_unistr(STREAM s, char *string, int len) |
123 |
rdp_out_unistr(STREAM s, char *string, int len) |
121 |
{ |
124 |
{ |
122 |
int i = 0, j = 0; |
125 |
int i = 0, j = 0, initlen, avail; |
123 |
|
126 |
char *incharset, *wptr, *outstr; |
124 |
len += 2; |
127 |
iconv_t cd; |
125 |
|
128 |
|
126 |
while (i < len) |
129 |
incharset = nl_langinfo(CODESET); |
127 |
{ |
130 |
cd = iconv_open("UTF16LE", incharset); |
|
|
131 |
if(cd == (iconv_t)-1) |
132 |
{ |
133 |
if (errno == EINVAL) |
134 |
error (0, 0, "conversion from '%s' to 'UTF16LE' not available", incharset); |
135 |
else |
136 |
perror ("iconv_open"); |
137 |
error(0, 0, "Iconv conversion failed. Using build-in conversion to Latin1"); |
138 |
len += 2; |
139 |
while (i < len) |
140 |
{ |
128 |
s->p[i++] = string[j++]; |
141 |
s->p[i++] = string[j++]; |
129 |
s->p[i++] = 0; |
142 |
s->p[i++] = 0; |
130 |
} |
143 |
} |
131 |
|
144 |
s->p += len; |
132 |
s->p += len; |
145 |
return; |
|
|
146 |
} |
147 |
initlen = avail = len + 2; |
148 |
len = strlen(string); |
149 |
wptr = outstr = malloc(initlen); |
150 |
iconv(cd, &string, &len, &wptr, &avail); |
151 |
iconv_close(cd); |
152 |
memset(s->p, '\0', initlen - avail + 2); |
153 |
memcpy(s->p, outstr, initlen - avail); |
154 |
s->p += initlen - avail + 2; |
155 |
free(outstr); |
133 |
} |
156 |
} |
134 |
|
157 |
|
135 |
/* Parse a logon info packet */ |
158 |
/* Parse a logon info packet */ |