mirror of https://github.com/djcb/mu.git
* possible fix for some encoding problem (mu_util_fputs_encoded) + cosmetics
This commit is contained in:
parent
253d03aaaa
commit
6761f0e5d3
|
@ -633,13 +633,13 @@ output_plain_fields (MuMsg *msg, const char *fields,
|
||||||
if (mfid == MU_MSG_FIELD_ID_NONE ||
|
if (mfid == MU_MSG_FIELD_ID_NONE ||
|
||||||
(!mu_msg_field_xapian_value (mfid) &&
|
(!mu_msg_field_xapian_value (mfid) &&
|
||||||
!mu_msg_field_xapian_contact (mfid)))
|
!mu_msg_field_xapian_contact (mfid)))
|
||||||
nonempty += printf ("%c", *myfields);
|
nonempty += printf ("%c", *myfields);
|
||||||
|
|
||||||
else {
|
else {
|
||||||
ansi_color_maybe (mfid, color);
|
ansi_color_maybe (mfid, color);
|
||||||
nonempty += mu_util_fputs_encoded
|
nonempty += mu_util_fputs_encoded
|
||||||
(display_field (msg, mfid), stdout);
|
(display_field (msg, mfid), stdout);
|
||||||
ansi_reset_maybe (mfid, color);
|
ansi_reset_maybe (mfid, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -416,25 +416,26 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
||||||
GError *err;
|
GError *err;
|
||||||
unsigned bytes;
|
unsigned bytes;
|
||||||
err = NULL;
|
err = NULL;
|
||||||
|
|
||||||
conv = g_locale_from_utf8 (str, -1, &bytes, NULL, &err);
|
conv = g_locale_from_utf8 (str, -1, &bytes, NULL, &err);
|
||||||
if (err) {
|
if (!conv || err) {
|
||||||
/* conversion failed; this happens because is
|
/* conversion failed; this happens because is
|
||||||
* some cases GMime may gives us non-UTF-8
|
* some cases GMime may gives us non-UTF-8
|
||||||
* string from e.g. wrongly encoded
|
* string from e.g. wrongly encoded
|
||||||
* message-subjects; if so, we escape the
|
* message-subjects; if so, we escape the
|
||||||
* string */
|
* string */
|
||||||
|
g_warning ("%s: fputs failed: %s",
|
||||||
|
__FUNCTION__,
|
||||||
|
err ? err->message : "conversion failed");
|
||||||
|
g_clear_error (&err);
|
||||||
g_free (conv);
|
g_free (conv);
|
||||||
conv = g_strescape (str, NULL);
|
conv = g_strescape (str, NULL);
|
||||||
g_error_free (err);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
rv = fputs (conv, stream);
|
rv = fputs (conv, stream);
|
||||||
g_free (conv);
|
g_free (conv);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rv == EOF) { /* note, apparently, does not set errno */
|
if (rv == EOF) { /* note, apparently, does not set errno */
|
||||||
g_printerr ("fputs failed");
|
g_warning ("%s: fputs failed", __FUNCTION__);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,6 +443,7 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
print_args (FILE *stream, const char *frm, va_list args)
|
print_args (FILE *stream, const char *frm, va_list args)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue