Merge pull request #36 from llyzs/utf

Use towupper for unicode uppercase.
This commit is contained in:
Marc-André Moreau 2011-08-08 21:22:46 -07:00
commit 9f2a3e847b
3 changed files with 19 additions and 4 deletions

View File

@ -19,6 +19,7 @@
#include <errno.h>
#include <pthread.h>
#include <locale.h>
#include <freerdp/utils/args.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/semaphore.h>
@ -361,6 +362,8 @@ int main(int argc, char* argv[])
struct thread_data* data;
rdpChanMan* chanman;
setlocale(LC_ALL, "");
freerdp_chanman_global_init();
g_sem = freerdp_sem_new(1);

View File

@ -22,6 +22,7 @@
#include <errno.h>
#include <pthread.h>
#include <locale.h>
#include <sys/select.h>
#include <freerdp/utils/args.h>
#include <freerdp/utils/memory.h>
@ -522,6 +523,8 @@ int main(int argc, char* argv[])
struct thread_data* data;
rdpChanMan* chanman;
setlocale(LC_ALL, "");
freerdp_chanman_global_init();
g_sem = freerdp_sem_new(1);

View File

@ -18,6 +18,7 @@
*/
#include <errno.h>
#include <wctype.h>
#include <freerdp/utils/memory.h>
#include <freerdp/utils/unicode.h>
@ -187,13 +188,21 @@ char* freerdp_uniconv_out(UNICONV *uniconv, char *str, size_t *pout_len)
void freerdp_uniconv_uppercase(UNICONV *uniconv, char *wstr, int length)
{
int i;
char* p;
unsigned char* p;
unsigned int wc, uwc;
p = wstr;
p = (unsigned char*)wstr;
for (i = 0; i < length; i++)
{
if (p[i * 2] >= 'a' && p[i * 2] <= 'z')
p[i * 2] = p[i * 2] - 32;
wc = (unsigned int)(*p);
wc += (unsigned int)(*(p + 1)) << 8;
uwc = towupper(wc);
if (uwc != wc)
{
*p = uwc & 0xFF;
*(p + 1) = (uwc >> 8) & 0xFF;
}
p += 2;
}
}