degesch: detect //TRANSLIT support, use cp1252
Now BSDs should have it enabled as well.
This commit is contained in:
36
degesch.c
36
degesch.c
@@ -2021,6 +2021,20 @@ filter_color_cube_for_acceptable_nick_colors (size_t *len)
|
||||
return table;
|
||||
}
|
||||
|
||||
static bool
|
||||
app_iconv_open (iconv_t *target, const char *to, const char *from)
|
||||
{
|
||||
if (ICONV_ACCEPTS_TRANSLIT)
|
||||
{
|
||||
char *to_real = xstrdup_printf ("%s//TRANSLIT", to);
|
||||
*target = iconv_open (to_real, from);
|
||||
free (to_real);
|
||||
}
|
||||
else
|
||||
*target = iconv_open (to, from);
|
||||
return *target != (iconv_t) -1;
|
||||
}
|
||||
|
||||
static void
|
||||
app_context_init (struct app_context *self)
|
||||
{
|
||||
@@ -2040,25 +2054,15 @@ app_context_init (struct app_context *self)
|
||||
self->backlog_limit = 1000;
|
||||
self->last_displayed_msg_time = time (NULL);
|
||||
|
||||
char *encoding = nl_langinfo (CODESET);
|
||||
// FIXME: put a check for "//TRANSLIT" in CMakeLists.txt
|
||||
#ifdef __linux__
|
||||
encoding = xstrdup_printf ("%s//TRANSLIT", encoding);
|
||||
#else // ! __linux__
|
||||
encoding = xstrdup (encoding);
|
||||
#endif // ! __linux__
|
||||
|
||||
if ((self->term_from_utf8 =
|
||||
iconv_open (encoding, "UTF-8")) == (iconv_t) -1
|
||||
|| (self->latin1_to_utf8 =
|
||||
iconv_open ("UTF-8", "ISO-8859-1")) == (iconv_t) -1
|
||||
|| (self->term_to_utf8 =
|
||||
iconv_open ("UTF-8", nl_langinfo (CODESET))) == (iconv_t) -1)
|
||||
// Windows 1252 redefines several silly control characters as glyphs
|
||||
char *native = nl_langinfo (CODESET);
|
||||
if (!app_iconv_open (&self->term_from_utf8, native, "UTF-8")
|
||||
|| !app_iconv_open (&self->term_to_utf8, "UTF-8", native)
|
||||
|| (!app_iconv_open (&self->latin1_to_utf8, "UTF-8", "WINDOWS-1252")
|
||||
&& !app_iconv_open (&self->latin1_to_utf8, "UTF-8", "ISO-8859-1")))
|
||||
exit_fatal ("creating the UTF-8 conversion object failed: %s",
|
||||
strerror (errno));
|
||||
|
||||
free (encoding);
|
||||
|
||||
self->input = input_new ();
|
||||
self->input->user_data = self;
|
||||
str_vector_init (&self->pending_input);
|
||||
|
||||
Reference in New Issue
Block a user