diff options
author | jsorg71 <jsorg71> | 2007-09-23 07:43:16 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2007-09-23 07:43:16 +0000 |
commit | 7f919dc17e445c5fec4a0636b3d37b1f4da47a3d (patch) | |
tree | 6ed9a6d0716a52ceb055091cb840680c1c45d463 | |
parent | 719b13b38825d3439dbeb4ab7df24acbf0679ddc (diff) | |
download | xrdp-proprietary-7f919dc17e445c5fec4a0636b3d37b1f4da47a3d.tar.gz xrdp-proprietary-7f919dc17e445c5fec4a0636b3d37b1f4da47a3d.zip |
unicode
-rw-r--r-- | xrdp/funcs.c | 63 | ||||
-rw-r--r-- | xrdp/xrdp.c | 1 |
2 files changed, 48 insertions, 16 deletions
diff --git a/xrdp/funcs.c b/xrdp/funcs.c index 191ee3b4..0f92b600 100644 --- a/xrdp/funcs.c +++ b/xrdp/funcs.c @@ -147,24 +147,31 @@ check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy) /* add a ch at index position in text, index starts at 0 */ /* if index = -1 add it to the end */ int APP_CC -add_char_at(char* text, char ch, int index) +add_char_at(char* text, int text_size, twchar ch, int index) { int len; int i; + twchar* wstr; - len = g_strlen(text); - if (index >= len || index < 0) + len = g_mbstowcs(0, text, 0); + wstr = (twchar*)g_malloc((len + 16) * sizeof(twchar), 0); + g_mbstowcs(wstr, text, len + 1); + if ((index >= len) || (index < 0)) { - text[len] = ch; - text[len + 1] = 0; + wstr[len] = ch; + wstr[len + 1] = 0; + g_wcstombs(text, wstr, text_size); + g_free(wstr); return 0; } - for (i = len - 1; i >= index; i--) + for (i = (len - 1); i >= index; i--) { - text[i + 1] = text[i]; + wstr[i + 1] = wstr[i]; } - text[i + 1] = ch; - text[len + 1] = 0; + wstr[i + 1] = ch; + wstr[len + 1] = 0; + g_wcstombs(text, wstr, text_size); + g_free(wstr); return 0; } @@ -172,26 +179,33 @@ add_char_at(char* text, char ch, int index) /* remove a ch at index position in text, index starts at 0 */ /* if index = -1 remove it from the end */ int APP_CC -remove_char_at(char* text, int index) +remove_char_at(char* text, int text_size, int index) { int len; int i; + twchar* wstr; - len = g_strlen(text); + len = g_mbstowcs(0, text, 0); if (len <= 0) { return 0; } - if (index >= len - 1 || index < 0) + wstr = (twchar*)g_malloc((len + 16) * sizeof(twchar), 0); + g_mbstowcs(wstr, text, len + 1); + if ((index >= (len - 1)) || (index < 0)) { - text[len - 1] = 0; + wstr[len - 1] = 0; + g_wcstombs(text, wstr, text_size); + g_free(wstr); return 0; } - for (i = index; i < len - 1; i++) + for (i = index; i < (len - 1); i++) { - text[i] = text[i + 1]; + wstr[i] = wstr[i + 1]; } - text[len - 1] = 0; + wstr[len - 1] = 0; + g_wcstombs(text, wstr, text_size); + g_free(wstr); return 0; } @@ -207,3 +221,20 @@ set_string(char** in_str, const char* in) *in_str = g_strdup(in); return 0; } + +/*****************************************************************************/ +int APP_CC +wchar_repeat(twchar* dest, int dest_size_in_wchars, twchar ch, int repeat) +{ + int index; + + for (index = 0; index < repeat; index++) + { + if (index >= dest_size_in_wchars) + { + break; + } + dest[index] = ch; + } + return 0; +} diff --git a/xrdp/xrdp.c b/xrdp/xrdp.c index f3ecb38c..3016760f 100644 --- a/xrdp/xrdp.c +++ b/xrdp/xrdp.c @@ -262,6 +262,7 @@ main(int argc, char** argv) char text[32]; #endif + g_init(); /* check compiled endian with actual endian */ test = 1; host_be = !((int)(*(unsigned char*)(&test))); |