aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorLauris Kaplinski <lauris@src.gnome.org>2000-09-13 05:19:44 +0800
committerLauris Kaplinski <lauris@src.gnome.org>2000-09-13 05:19:44 +0800
commit4e5594955f8a2b35741855526b3190301f795911 (patch)
tree8850a6a734b6f140100f5aa17328284f0b0c6ee7 /e-util
parentee5fca52e1821c11907c7feba961ab97d32050dd (diff)
downloadgsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar.gz
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar.bz2
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar.lz
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar.xz
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.tar.zst
gsoc2013-evolution-4e5594955f8a2b35741855526b3190301f795911.zip
Use underscores for untranslated characters fro Gtk+
svn path=/trunk/; revision=5391
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog6
-rw-r--r--e-util/e-unicode.c94
2 files changed, 48 insertions, 52 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index ed5fa74aca..b5ae0307d0 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,9 @@
+2000-09-12 Lauris Kaplinski <lauris@helixcode.com>
+
+ * e-unicode.c (e_utf8_to_gtk_string_sized): Use underscores
+ for untranslatable characters
+ (e_utf8_from_gtk_string_sized): Ditto
+
2000-09-12 Dan Winship <danw@helixcode.com>
* e-font.c (e_font_from_gdk_font): Change this a bit so that if
diff --git a/e-util/e-unicode.c b/e-util/e-unicode.c
index 748f38a83a..976d119d36 100644
--- a/e-util/e-unicode.c
+++ b/e-util/e-unicode.c
@@ -97,50 +97,45 @@ e_utf8_from_gtk_event_key (GtkWidget *widget, guint keyval, const gchar *string)
gchar *
e_utf8_from_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes)
{
-#ifndef FONT_TESTING
- /* test it out with iso-8859-1 */
-
- static gboolean uinit = FALSE;
- static gboolean uerror = FALSE;
- static unicode_iconv_t uiconv = (unicode_iconv_t) -1;
-#else
unicode_iconv_t uiconv;
-#endif
char *new, *ob;
+ const gchar * ib;
size_t ibl, obl;
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-#ifndef FONT_TESTING
- if (uerror) return NULL;
-#endif
-
if (!string) return NULL;
g_return_val_if_fail (widget, NULL);
-#ifndef FONT_TESTING
- if (!uinit) {
- e_unicode_init ();
- uiconv = unicode_iconv_open ("UTF-8", "iso-8859-1");
- if (uiconv == (unicode_iconv_t) -1) {
- uerror = TRUE;
- return NULL;
- } else {
- uinit = TRUE;
- }
- }
-#else
uiconv = e_uiconv_from_gdk_font (widget->style->font);
if (uiconv == (unicode_iconv_t) -1) return NULL;
-#endif
+ ib = string;
ibl = bytes;
new = ob = g_new (gchar, ibl * 6 + 1);
obl = ibl * 6 + 1;
- unicode_iconv (uiconv, &string, &ibl, &ob, &obl);
+ while (ibl > 0) {
+ unicode_iconv (uiconv, &ib, &ibl, &ob, &obl);
+ if (ibl > 0) {
+ gint len;
+ if ((*ib & 0x80) == 0x00) len = 1;
+ else if ((*ib &0xe0) == 0xc0) len = 2;
+ else if ((*ib &0xf0) == 0xe0) len = 3;
+ else if ((*ib &0xf80) == 0xf0) len = 4;
+ else {
+ g_warning ("Invalid UTF-8 sequence");
+ break;
+ }
+ ib += len;
+ ibl = bytes - (ib - string);
+ if (ibl > bytes) ibl = 0;
+ *ob++ = '_';
+ obl--;
+ }
+ }
*ob = '\0';
@@ -156,47 +151,42 @@ e_utf8_from_gtk_string (GtkWidget *widget, const gchar *string)
gchar *
e_utf8_to_gtk_string_sized (GtkWidget *widget, const gchar *string, gint bytes)
{
-#ifndef FONT_TESTING
- /* test it out with iso-8859-1 */
-
- static gboolean uinit = FALSE;
- static gboolean uerror = FALSE;
- static unicode_iconv_t uiconv = (unicode_iconv_t) -1;
-#else
unicode_iconv_t uiconv;
-#endif
char *new, *ob;
+ const gchar * ib;
size_t ibl, obl;
-#ifndef FONT_TESTING
- if (uerror) return NULL;
-#endif
-
if (!string) return NULL;
g_return_val_if_fail (widget, NULL);
-#ifndef FONT_TESTING
- if (!uinit) {
- e_unicode_init ();
- uiconv = unicode_iconv_open ("iso-8859-1", "UTF-8");
- if (uiconv == (unicode_iconv_t) -1) {
- uerror = TRUE;
- return NULL;
- } else {
- uinit = TRUE;
- }
- }
-#else
uiconv = e_uiconv_to_gdk_font (widget->style->font);
if (uiconv == (unicode_iconv_t) -1) return NULL;
-#endif
+ ib = string;
ibl = bytes;
new = ob = g_new (gchar, ibl * 4 + 1);
obl = ibl * 4 + 1;
- unicode_iconv (uiconv, &string, &ibl, &ob, &obl);
+ while (ibl > 0) {
+ unicode_iconv (uiconv, &ib, &ibl, &ob, &obl);
+ if (ibl > 0) {
+ gint len;
+ if ((*ib & 0x80) == 0x00) len = 1;
+ else if ((*ib &0xe0) == 0xc0) len = 2;
+ else if ((*ib &0xf0) == 0xe0) len = 3;
+ else if ((*ib &0xf80) == 0xf0) len = 4;
+ else {
+ g_warning ("Invalid UTF-8 sequence");
+ break;
+ }
+ ib += len;
+ ibl = bytes - (ib - string);
+ if (ibl > bytes) ibl = 0;
+ *ob++ = '_';
+ obl--;
+ }
+ }
*ob = '\0';