CVS: seamlessrdp/ServerExe vchannel.c,1.8,1.9 vchannel.h,1.5,1.6
Pierre Ossman <[email protected]> Wed, 15 Mar 2006 05:19:59 -0800
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/seamlessrdp/ServerExe
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11816/ServerExe
Modified Files:
vchannel.c vchannel.h
Log Message:
Get window titles in unicode and send them over the channel in UTF-8. This
also meant that we had to catch WM_SETTEXT after it was handled (so that we
can use GetWindowTextW()).
Index: vchannel.c
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** vchannel.c 15 Mar 2006 12:08:32 -0000 1.8
--- vchannel.c 15 Mar 2006 13:19:53 -0000 1.9
***************
*** 56,59 ****
--- 56,116 ----
}
+ #define CONVERT_BUFFER_SIZE 1024
+ static char convert_buffer[CONVERT_BUFFER_SIZE];
+
+ const char *
+ unicode_to_utf8(const unsigned short *string)
+ {
+ unsigned char *buf;
+ size_t size;
+
+ buf = (unsigned char *) convert_buffer;
+ size = sizeof(convert_buffer) - 1;
+
+ /* We do not handle characters outside BMP (i.e. we can't do UTF-16) */
+ while (*string != 0x0000)
+ {
+ if (*string < 0x80)
+ {
+ if (size < 1)
+ break;
+ *buf++ = (unsigned char) *string;
+ size--;
+ }
+ else if (*string < 0x800)
+ {
+ if (size < 2)
+ break;
+ *buf++ = 0xC0 | (*string >> 6);
+ *buf++ = 0x80 | (*string & 0x3F);
+ size -= 2;
+ }
+ else if (*string < 0x10000)
+ {
+ if (size < 3)
+ break;
+ *buf++ = 0xE0 | (*string >> 12);
+ *buf++ = 0x80 | (*string >> 6 & 0x3F);
+ *buf++ = 0x80 | (*string & 0x3F);
+ size -= 2;
+ }
+ else if (*string < 0x200000)
+ {
+ if (size < 4)
+ break;
+ *buf++ = 0xF0 | (*string >> 18);
+ *buf++ = 0x80 | (*string >> 12 & 0x3F);
+ *buf++ = 0x80 | (*string >> 6 & 0x3F);
+ *buf++ = 0x80 | (*string & 0x3F);
+ size -= 2;
+ }
+
+ string++;
+ }
+
+ *buf = '\0';
+
+ return convert_buffer;
+ }
int
***************
*** 222,223 ****
--- 279,286 ----
return string;
}
+
+ const char *
+ vchannel_strfilter_unicode(const unsigned short *string)
+ {
+ return vchannel_strfilter((char *) unicode_to_utf8(string));
+ }
Index: vchannel.h
===================================================================
RCS file: /cvsroot/rdesktop/seamlessrdp/ServerExe/vchannel.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** vchannel.h 10 Mar 2006 16:41:49 -0000 1.5
--- vchannel.h 15 Mar 2006 13:19:53 -0000 1.6
***************
*** 27,30 ****
--- 27,32 ----
void debug(char *format, ...);
+ const char *unicode_to_utf8(const unsigned short *string);
+
int vchannel_open();
void vchannel_close();
***************
*** 40,43 ****
--- 42,46 ----
const char *vchannel_strfilter(char *string);
+ const char *vchannel_strfilter_unicode(const unsigned short *string);
#endif
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642