libpurple/util.c

changeset 28384
e167fb02072e
parent 28222
5643a627bc21
child 28388
d994de927848
equal deleted inserted replaced
28383:9dabcae067c0 28384:e167fb02072e
4658 return NULL; 4658 return NULL;
4659 4659
4660 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL); 4660 g_return_val_if_fail(g_utf8_validate(str, -1, NULL), NULL);
4661 4661
4662 workstr = iter = g_new(gchar, strlen(str) + 1); 4662 workstr = iter = g_new(gchar, strlen(str) + 1);
4663 while (*str) { 4663 for ( ; *str; ++str) {
4664 gunichar c = g_utf8_get_char(str); 4664 if (*str >= 0x20 || *str == 0x09 || *str == 0x0a || *str == 0x0d) {
4665 const gchar *next = g_utf8_next_char(str); 4665 *iter = *str;
4666 size_t len = next - str; 4666 ++iter;
4667 4667 }
4668 if (g_unichar_isprint(c)) {
4669 memcpy(iter, str, len);
4670 iter += len;
4671 }
4672
4673 str = next;
4674 } 4668 }
4675 4669
4676 /* nul-terminate the new string */ 4670 /* nul-terminate the new string */
4677 *iter = '\0'; 4671 *iter = '\0';
4678 4672

mercurial