Mercurial > pidgin.yaz
comparison finch/libgnt/gntmain.c @ 28984:a18f421696dc
Fix showing umlauts etc. on non-utf8 locales.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Fri, 20 Nov 2009 21:45:44 +0000 |
parents | de2ac0952487 |
children | a8cc50c2279f |
comparison
equal
deleted
inserted
replaced
28983:8356e2f2486a | 28984:a18f421696dc |
---|---|
79 | 79 |
80 static gboolean refresh_screen(void); | 80 static gboolean refresh_screen(void); |
81 | 81 |
82 static GntWM *wm; | 82 static GntWM *wm; |
83 static GntClipboard *clipboard; | 83 static GntClipboard *clipboard; |
84 | |
85 int gnt_need_conversation_to_locale; | |
84 | 86 |
85 #define HOLDING_ESCAPE (escape_stuff.timer != 0) | 87 #define HOLDING_ESCAPE (escape_stuff.timer != 0) |
86 | 88 |
87 static struct { | 89 static struct { |
88 int timer; | 90 int timer; |
463 setup_io(); | 465 setup_io(); |
464 | 466 |
465 #ifdef NO_WIDECHAR | 467 #ifdef NO_WIDECHAR |
466 ascii_only = TRUE; | 468 ascii_only = TRUE; |
467 #else | 469 #else |
468 if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) | 470 if (locale && (strstr(locale, "UTF") || strstr(locale, "utf"))) { |
469 ascii_only = FALSE; | 471 ascii_only = FALSE; |
470 else | 472 } else { |
471 ascii_only = TRUE; | 473 ascii_only = TRUE; |
474 gnt_need_conversation_to_locale = TRUE; | |
475 } | |
472 #endif | 476 #endif |
473 | 477 |
474 initscr(); | 478 initscr(); |
475 typeahead(-1); | 479 typeahead(-1); |
476 noecho(); | 480 noecho(); |
729 #else | 733 #else |
730 return FALSE; | 734 return FALSE; |
731 #endif | 735 #endif |
732 } | 736 } |
733 | 737 |
738 const char *C_(const char *x) | |
739 { | |
740 static char *c = NULL; | |
741 if (gnt_need_conversation_to_locale) { | |
742 GError *error = NULL; | |
743 g_free(c); | |
744 c = g_locale_from_utf8(x, -1, NULL, NULL, &error); | |
745 if (c == NULL || error) { | |
746 char *store = c; | |
747 c = NULL; | |
748 gnt_warning("Error: %s\n", error ? error->message : "(unknown)"); | |
749 g_error_free(error); | |
750 error = NULL; | |
751 g_free(c); | |
752 c = store; | |
753 } | |
754 return c ? c : x; | |
755 } else | |
756 return x; | |
757 } | |
758 |