mirror of
https://github.com/irssi/irssi.git
synced 2024-12-04 14:46:39 -05:00
If transliterations don't work in the system (eg. Solaris), don't allow
recode_transliterate setting to be enabled. git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4082 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
parent
5178a643bb
commit
342141fcb2
@ -37,19 +37,31 @@ static gboolean recode_get_charset(const char **charset)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static gboolean is_translit(const char *charset)
|
||||||
|
{
|
||||||
|
char *pos;
|
||||||
|
pos = stristr(charset, "//translit");
|
||||||
|
return (pos != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
gboolean is_valid_charset(const char *charset)
|
gboolean is_valid_charset(const char *charset)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
const char *from="UTF-8";
|
const char *from="UTF-8";
|
||||||
const char *str="irssi";
|
const char *str="irssi";
|
||||||
char *recoded;
|
char *recoded, *to = NULL;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
|
|
||||||
if (!charset || *charset == '\0')
|
if (!charset || *charset == '\0')
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
if (settings_get_bool("recode_transliterate") && !is_translit(charset))
|
||||||
|
charset = to = g_strconcat(charset, "//TRANSLIT", NULL);
|
||||||
|
|
||||||
recoded = g_convert(str, strlen(str), charset, from, NULL, NULL, NULL);
|
recoded = g_convert(str, strlen(str), charset, from, NULL, NULL, NULL);
|
||||||
valid = (recoded != NULL);
|
valid = (recoded != NULL);
|
||||||
g_free(recoded);
|
g_free(recoded);
|
||||||
|
g_free(to);
|
||||||
return valid;
|
return valid;
|
||||||
#else
|
#else
|
||||||
if (!charset || *charset =='\0')
|
if (!charset || *charset =='\0')
|
||||||
@ -58,13 +70,6 @@ gboolean is_valid_charset(const char *charset)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean is_translit(const char *charset)
|
|
||||||
{
|
|
||||||
char *pos;
|
|
||||||
pos = stristr(charset, "//translit");
|
|
||||||
return (pos != NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_GLIB2
|
#ifdef HAVE_GLIB2
|
||||||
|
@ -156,6 +156,15 @@ static void read_settings(void)
|
|||||||
char *old_recode_fallback = g_strdup(recode_fallback);
|
char *old_recode_fallback = g_strdup(recode_fallback);
|
||||||
char *old_recode_out_default = g_strdup(recode_out_default);
|
char *old_recode_out_default = g_strdup(recode_out_default);
|
||||||
|
|
||||||
|
if (settings_get_bool("recode_transliterate")) {
|
||||||
|
/* check if transliterations are supported in this system */
|
||||||
|
if (!is_valid_charset("ASCII")) {
|
||||||
|
printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
|
||||||
|
TXT_CONVERSION_NO_TRANSLITS);
|
||||||
|
settings_set_bool("recode_transliterate", FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (recode_fallback)
|
if (recode_fallback)
|
||||||
g_free(recode_fallback);
|
g_free(recode_fallback);
|
||||||
recode_fallback = g_strdup(settings_get_str("recode_fallback"));
|
recode_fallback = g_strdup(settings_get_str("recode_fallback"));
|
||||||
|
@ -255,6 +255,7 @@ FORMAT_REC fecommon_core_formats[] = {
|
|||||||
{ "conversion_added", "Added {hilight $0}/{hilight $1} to conversion database", 2, { FORMAT_STRING, FORMAT_STRING } },
|
{ "conversion_added", "Added {hilight $0}/{hilight $1} to conversion database", 2, { FORMAT_STRING, FORMAT_STRING } },
|
||||||
{ "conversion_removed", "Removed {hilight $0} from conversion database", 1, { FORMAT_STRING } },
|
{ "conversion_removed", "Removed {hilight $0} from conversion database", 1, { FORMAT_STRING } },
|
||||||
{ "conversion_not_found", "{hilight $0} not found in conversion database", 1, { FORMAT_STRING } },
|
{ "conversion_not_found", "{hilight $0} not found in conversion database", 1, { FORMAT_STRING } },
|
||||||
|
{ "conversion_no_translits", "Transliterations not supported in this system", 0 },
|
||||||
{ "recode_header", "%#Target Character set", 0 },
|
{ "recode_header", "%#Target Character set", 0 },
|
||||||
{ "recode_line", "%#%|$[!30]0 $1", 2, { FORMAT_STRING, FORMAT_STRING } },
|
{ "recode_line", "%#%|$[!30]0 $1", 2, { FORMAT_STRING, FORMAT_STRING } },
|
||||||
|
|
||||||
|
@ -221,6 +221,7 @@ enum {
|
|||||||
TXT_CONVERSION_ADDED,
|
TXT_CONVERSION_ADDED,
|
||||||
TXT_CONVERSION_REMOVED,
|
TXT_CONVERSION_REMOVED,
|
||||||
TXT_CONVERSION_NOT_FOUND,
|
TXT_CONVERSION_NOT_FOUND,
|
||||||
|
TXT_CONVERSION_NO_TRANSLITS,
|
||||||
TXT_RECODE_HEADER,
|
TXT_RECODE_HEADER,
|
||||||
TXT_RECODE_LINE,
|
TXT_RECODE_LINE,
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user