1
0
mirror of https://github.com/irssi/irssi.git synced 2024-09-01 04:14:16 -04:00

Add public is_utf8 function by refactoring existing code.

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4368 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Emanuele Giaquinta 2006-09-20 23:04:40 +00:00 committed by exg
parent 6e3870af5c
commit 3cdf50170f
3 changed files with 15 additions and 15 deletions

View File

@ -25,7 +25,6 @@
#include "lib-config/iconfig.h"
#include "misc.h"
#ifdef HAVE_GLIB2
static gboolean recode_get_charset(const char **charset)
{
*charset = settings_get_str("term_charset");
@ -33,9 +32,19 @@ static gboolean recode_get_charset(const char **charset)
/* we use the same test as in src/fe-text/term.c:123 */
return !g_strcasecmp(*charset, "utf-8");
#ifdef HAVE_GLIB2
return g_get_charset(charset);
}
#else
return FALSE;
#endif
}
gboolean is_utf8(void)
{
const char *charset;
return recode_get_charset(&charset);
}
static gboolean is_translit(const char *charset)
{

View File

@ -4,6 +4,7 @@
char *recode_in (const SERVER_REC *server, const char *str, const char *target);
char *recode_out (const SERVER_REC *server, const char *str, const char *target);
gboolean is_valid_charset(const char *charset);
gboolean is_utf8(void);
void recode_init (void);
void recode_deinit (void);

View File

@ -33,6 +33,7 @@
#include "themes.h"
#include "translation.h"
#ifdef HAVE_GLIB2
#include "recode.h"
#include "utf8.h"
#endif
@ -299,17 +300,6 @@ void format_create_dest_tag(TEXT_DEST_REC *dest, void *server,
window_find_closest(server, target, level);
}
#ifdef HAVE_GLIB2
static gboolean term_is_utf8 (void)
{
const char *charset;
charset = settings_get_str("term_charset");
if (*charset)
return ! g_strcasecmp(charset, "utf-8");
return g_get_charset(&charset);
}
static int advance (char const **str, gboolean utf8)
{
if (utf8) {
@ -338,7 +328,7 @@ int format_get_length(const char *str)
g_return_val_if_fail(str != NULL, 0);
#ifdef HAVE_GLIB2
utf8 = term_is_utf8() && g_utf8_validate(str, -1, NULL);
utf8 = is_utf8() && g_utf8_validate(str, -1, NULL);
#endif
tmp = g_string_new(NULL);
@ -382,7 +372,7 @@ int format_real_length(const char *str, int len)
g_return_val_if_fail(len >= 0, 0);
#ifdef HAVE_GLIB2
utf8 = term_is_utf8() && g_utf8_validate(str, -1, NULL);
utf8 = is_utf8() && g_utf8_validate(str, -1, NULL);
#endif
start = str;