diff options
author | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-08-16 17:53:43 +0000 |
---|---|---|
committer | gerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7> | 2010-08-16 17:53:43 +0000 |
commit | 49698a53bbf0266156a74aadfa60841cd33b2233 (patch) | |
tree | 7883fad4f3899cddba9efc12afbdaaf68ee3b8e1 /gtk | |
parent | 0269a035cfd7ce99a38a64b4e2cef13b414f3d5f (diff) |
Don't drop characters in the middle of a UTF-8 sequence. Fixes bug 5066.
Use an ellipsis character instead of three dots.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@33816 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/main_welcome.c | 16 | ||||
-rw-r--r-- | gtk/utf8_entities.h | 14 |
2 files changed, 21 insertions, 9 deletions
diff --git a/gtk/main_welcome.c b/gtk/main_welcome.c index 24078a7d56..16aef36a51 100644 --- a/gtk/main_welcome.c +++ b/gtk/main_welcome.c @@ -58,6 +58,7 @@ #include "gtk/capture_dlg.h" #include "gtk/capture_if_dlg.h" #include "gtk/capture_globals.h" +#include "gtk/utf8_entities.h" #endif #include "../image/wssplash-dev.xpm" #include "../version_info.h" @@ -420,9 +421,11 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label) GtkWidget *eb; GString *str; gchar *str_escaped; + glong uni_len; + gsize uni_start, uni_end; const unsigned int max = 60; - int err; - struct stat stat_buf; + int err; + struct stat stat_buf; GtkTooltips *tooltips; @@ -430,11 +433,14 @@ welcome_filename_link_new(const gchar *filename, GtkWidget **label) /* filename */ str = g_string_new(filename); + uni_len = g_utf8_strlen(str->str, str->len); /* cut max filename length */ - if( (str->len > max) && (str->len-(max) > 5) ) { - g_string_erase(str, 20, str->len-(max+5)); - g_string_insert(str, 20, " ... "); + if (uni_len > max) { + uni_start = g_utf8_offset_to_pointer(str->str, 20) - str->str; + uni_end = g_utf8_offset_to_pointer(str->str, uni_len - max) - str->str; + g_string_erase(str, uni_start, uni_end); + g_string_insert(str, uni_start, " " UTF8_HORIZONTAL_ELLIPSIS " "); } /* escape the possibly shortened filename before adding pango language */ diff --git a/gtk/utf8_entities.h b/gtk/utf8_entities.h index 8e782f50c2..d7189fa323 100644 --- a/gtk/utf8_entities.h +++ b/gtk/utf8_entities.h @@ -26,10 +26,16 @@ #ifndef __UTF8_ENTITIES_H__ #define __UTF8_ENTITIES_H__ -/* Sequences can be found at http://www.utf8-chartable.de/ among other places */ +/* + * Sequences can be found at + * http://www.fileformat.info/info/unicode/ + * http://www.utf8-chartable.de/ + * and other places + */ -#define UTF8_LEFTWARDS_ARROW "\xe2\x86\x90" -#define UTF8_RIGHTWARDS_ARROW "\xe2\x86\x92" -#define UTF8_LEFT_RIGHT_ARROW "\xe2\x86\x94" +#define UTF8_HORIZONTAL_ELLIPSIS "\xe2\x80\xa6" +#define UTF8_LEFTWARDS_ARROW "\xe2\x86\x90" +#define UTF8_RIGHTWARDS_ARROW "\xe2\x86\x92" +#define UTF8_LEFT_RIGHT_ARROW "\xe2\x86\x94" #endif /* __UTF8_ENTITIES_H__ */ |