157 |
{ |
{ |
158 |
uint8 *result; |
uint8 *result; |
159 |
uint16 *inptr, *outptr; |
uint16 *inptr, *outptr; |
160 |
|
Bool swap_endianess; |
161 |
|
|
162 |
/* Worst case: Every char is LF */ |
/* Worst case: Every char is LF */ |
163 |
result = xmalloc((*size * 2) + 2); |
result = xmalloc((*size * 2) + 2); |
168 |
outptr = (uint16 *) result; |
outptr = (uint16 *) result; |
169 |
|
|
170 |
/* Check for a reversed BOM */ |
/* Check for a reversed BOM */ |
171 |
Bool swap_endianess = (*inptr == 0xfffe); |
swap_endianess = (*inptr == 0xfffe); |
172 |
|
|
173 |
while ((uint8 *) inptr < data + *size) |
while ((uint8 *) inptr < data + *size) |
174 |
{ |
{ |
293 |
if (target == format_string_atom || |
if (target == format_string_atom || |
294 |
target == format_unicode_atom || target == format_utf8_string_atom) |
target == format_unicode_atom || target == format_utf8_string_atom) |
295 |
{ |
{ |
296 |
|
size_t unicode_buffer_size; |
297 |
|
char *unicode_buffer; |
298 |
|
iconv_t cd; |
299 |
|
size_t unicode_buffer_size_remaining; |
300 |
|
char *unicode_buffer_remaining; |
301 |
|
char *data_remaining; |
302 |
|
size_t data_size_remaining; |
303 |
|
uint32 translated_data_size; |
304 |
|
uint8 *translated_data; |
305 |
|
|
306 |
if (rdp_clipboard_request_format != RDP_CF_TEXT) |
if (rdp_clipboard_request_format != RDP_CF_TEXT) |
307 |
return False; |
return False; |
308 |
|
|
311 |
to it, so using CF_TEXT is not safe (and is unnecessary, since all |
to it, so using CF_TEXT is not safe (and is unnecessary, since all |
312 |
WinNT versions are Unicode-minded). |
WinNT versions are Unicode-minded). |
313 |
*/ |
*/ |
|
size_t unicode_buffer_size; |
|
|
char *unicode_buffer; |
|
|
iconv_t cd; |
|
|
|
|
314 |
if (target == format_string_atom) |
if (target == format_string_atom) |
315 |
{ |
{ |
316 |
char *locale_charset = nl_langinfo(CODESET); |
char *locale_charset = nl_langinfo(CODESET); |
349 |
} |
} |
350 |
|
|
351 |
unicode_buffer = xmalloc(unicode_buffer_size); |
unicode_buffer = xmalloc(unicode_buffer_size); |
352 |
size_t unicode_buffer_size_remaining = unicode_buffer_size; |
unicode_buffer_size_remaining = unicode_buffer_size; |
353 |
char *unicode_buffer_remaining = unicode_buffer; |
unicode_buffer_remaining = unicode_buffer; |
354 |
char *data_remaining = (char *) source; |
data_remaining = (char *) source; |
355 |
size_t data_size_remaining = source_size; |
data_size_remaining = source_size; |
356 |
iconv(cd, (ICONV_CONST char **) &data_remaining, &data_size_remaining, |
iconv(cd, (ICONV_CONST char **) &data_remaining, &data_size_remaining, |
357 |
&unicode_buffer_remaining, &unicode_buffer_size_remaining); |
&unicode_buffer_remaining, &unicode_buffer_size_remaining); |
358 |
iconv_close(cd); |
iconv_close(cd); |
359 |
|
|
360 |
/* translate linebreaks */ |
/* translate linebreaks */ |
361 |
uint32 translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining; |
translated_data_size = unicode_buffer_size - unicode_buffer_size_remaining; |
362 |
uint8 *translated_data = |
translated_data = utf16_lf2crlf((uint8 *) unicode_buffer, &translated_data_size); |
|
utf16_lf2crlf((uint8 *) unicode_buffer, &translated_data_size); |
|
363 |
if (translated_data != NULL) |
if (translated_data != NULL) |
364 |
{ |
{ |
365 |
DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n", |
DEBUG_CLIPBOARD(("Sending Unicode string of %d bytes\n", |