mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05: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:
parent
6e3870af5c
commit
3cdf50170f
@ -25,7 +25,6 @@
|
|||||||
#include "lib-config/iconfig.h"
|
#include "lib-config/iconfig.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
|
||||||
#ifdef HAVE_GLIB2
|
|
||||||
static gboolean recode_get_charset(const char **charset)
|
static gboolean recode_get_charset(const char **charset)
|
||||||
{
|
{
|
||||||
*charset = settings_get_str("term_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 */
|
/* we use the same test as in src/fe-text/term.c:123 */
|
||||||
return !g_strcasecmp(*charset, "utf-8");
|
return !g_strcasecmp(*charset, "utf-8");
|
||||||
|
|
||||||
|
#ifdef HAVE_GLIB2
|
||||||
return g_get_charset(charset);
|
return g_get_charset(charset);
|
||||||
}
|
#else
|
||||||
|
return FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean is_utf8(void)
|
||||||
|
{
|
||||||
|
const char *charset;
|
||||||
|
|
||||||
|
return recode_get_charset(&charset);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean is_translit(const char *charset)
|
static gboolean is_translit(const char *charset)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
char *recode_in (const SERVER_REC *server, const char *str, const char *target);
|
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);
|
char *recode_out (const SERVER_REC *server, const char *str, const char *target);
|
||||||
gboolean is_valid_charset(const char *charset);
|
gboolean is_valid_charset(const char *charset);
|
||||||
|
gboolean is_utf8(void);
|
||||||
|
|
||||||
void recode_init (void);
|
void recode_init (void);
|
||||||
void recode_deinit (void);
|
void recode_deinit (void);
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "themes.h"
|
#include "themes.h"
|
||||||
#include "translation.h"
|
#include "translation.h"
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
|
#include "recode.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -299,17 +300,6 @@ void format_create_dest_tag(TEXT_DEST_REC *dest, void *server,
|
|||||||
window_find_closest(server, target, level);
|
window_find_closest(server, target, level);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_GLIB2
|
#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)
|
static int advance (char const **str, gboolean utf8)
|
||||||
{
|
{
|
||||||
if (utf8) {
|
if (utf8) {
|
||||||
@ -338,7 +328,7 @@ int format_get_length(const char *str)
|
|||||||
g_return_val_if_fail(str != NULL, 0);
|
g_return_val_if_fail(str != NULL, 0);
|
||||||
|
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
utf8 = term_is_utf8() && g_utf8_validate(str, -1, NULL);
|
utf8 = is_utf8() && g_utf8_validate(str, -1, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
tmp = g_string_new(NULL);
|
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);
|
g_return_val_if_fail(len >= 0, 0);
|
||||||
|
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
utf8 = term_is_utf8() && g_utf8_validate(str, -1, NULL);
|
utf8 = is_utf8() && g_utf8_validate(str, -1, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
start = str;
|
start = str;
|
||||||
|
Loading…
Reference in New Issue
Block a user