diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-12-09 11:59:16 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-12-09 11:59:16 +0000 |
commit | d71aea5b2b077e897d7ed44c641382f0807605ac (patch) | |
tree | d4ea0b68090021181662c2c79eb9d3c72d86c8dd /src/fe-text/gui-entry.c | |
parent | cba61999582924c6922a67c8ebe7530982abb1ee (diff) | |
download | irssi-d71aea5b2b077e897d7ed44c641382f0807605ac.zip |
Remove internal utf8 functions in favour of glib ones.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4958 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-text/gui-entry.c')
-rw-r--r-- | src/fe-text/gui-entry.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/fe-text/gui-entry.c b/src/fe-text/gui-entry.c index 9ed21cb3..13cbfafd 100644 --- a/src/fe-text/gui-entry.c +++ b/src/fe-text/gui-entry.c @@ -400,10 +400,10 @@ char *gui_entry_get_text(GUI_ENTRY_REC *entry) g_return_val_if_fail(entry != NULL, NULL); - buf = g_malloc(entry->text_len*6 + 1); if (entry->utf8) - utf16_to_utf8(entry->text, buf); + buf = g_ucs4_to_utf8(entry->text, -1, NULL, NULL, NULL); else { + buf = g_malloc(entry->text_len*6 + 1); if (term_type == TERM_TYPE_BIG5) unichars_to_big5(entry->text, buf); else @@ -420,10 +420,11 @@ char *gui_entry_get_text_and_pos(GUI_ENTRY_REC *entry, int *pos) g_return_val_if_fail(entry != NULL, NULL); - buf = g_malloc(entry->text_len*6 + 1); - if (entry->utf8) - utf16_to_utf8_with_pos(entry->text, entry->pos, buf, pos); - else { + if (entry->utf8) { + buf = g_ucs4_to_utf8(entry->text, -1, NULL, NULL, NULL); + *pos = g_utf8_offset_to_pointer(buf, entry->pos) - buf; + } else { + buf = g_malloc(entry->text_len*6 + 1); if(term_type==TERM_TYPE_BIG5) unichars_to_big5_with_pos(entry->text, entry->pos, buf, pos); else @@ -440,15 +441,17 @@ void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str) { unichar chr; int i, len; + const char *ptr; g_return_if_fail(entry != NULL); g_return_if_fail(str != NULL); gui_entry_redraw_from(entry, entry->pos); - if (entry->utf8) - len = strlen_utf8(str); - else if (term_type == TERM_TYPE_BIG5) + if (entry->utf8) { + g_utf8_validate(str, -1, &ptr); + len = g_utf8_pointer_to_offset(str, ptr); + } else if (term_type == TERM_TYPE_BIG5) len = strlen_big5(str); else len = strlen(str); @@ -468,9 +471,11 @@ void gui_entry_insert_text(GUI_ENTRY_REC *entry, const char *str) entry->text[entry->pos + i] = str[i]; } } else { - chr = entry->text[entry->pos+len]; - utf8_to_utf16(str, entry->text+entry->pos); - entry->text[entry->pos+len] = chr; + ptr = str; + for (i = 0; i < len; i++) { + entry->text[entry->pos + i] = g_utf8_get_char(ptr); + ptr = g_utf8_next_char(ptr); + } } entry->text_len += len; @@ -516,10 +521,10 @@ char *gui_entry_get_cutbuffer(GUI_ENTRY_REC *entry) if (entry->cutbuffer == NULL) return NULL; - buf = g_malloc(entry->cutbuffer_len*6 + 1); if (entry->utf8) - utf16_to_utf8(entry->cutbuffer, buf); + buf = g_ucs4_to_utf8(entry->cutbuffer, -1, NULL, NULL, NULL); else { + buf = g_malloc(entry->cutbuffer_len*6 + 1); if (term_type == TERM_TYPE_BIG5) unichars_to_big5(entry->cutbuffer, buf); else |