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 ||
|
||||
(!mu_msg_field_xapian_value (mfid) &&
|
||||
!mu_msg_field_xapian_contact (mfid)))
|
||||
nonempty += printf ("%c", *myfields);
|
||||
nonempty += printf ("%c", *myfields);
|
||||
|
||||
else {
|
||||
ansi_color_maybe (mfid, color);
|
||||
nonempty += mu_util_fputs_encoded
|
||||
(display_field (msg, mfid), stdout);
|
||||
ansi_reset_maybe (mfid, color);
|
||||
nonempty += mu_util_fputs_encoded
|
||||
(display_field (msg, mfid), stdout);
|
||||
ansi_reset_maybe (mfid, color);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -416,25 +416,26 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
|||
GError *err;
|
||||
unsigned bytes;
|
||||
err = NULL;
|
||||
|
||||
conv = g_locale_from_utf8 (str, -1, &bytes, NULL, &err);
|
||||
if (err) {
|
||||
if (!conv || err) {
|
||||
/* conversion failed; this happens because is
|
||||
* some cases GMime may gives us non-UTF-8
|
||||
* string from e.g. wrongly encoded
|
||||
* message-subjects; if so, we escape the
|
||||
* string */
|
||||
g_warning ("%s: fputs failed: %s",
|
||||
__FUNCTION__,
|
||||
err ? err->message : "conversion failed");
|
||||
g_clear_error (&err);
|
||||
g_free (conv);
|
||||
conv = g_strescape (str, NULL);
|
||||
g_error_free (err);
|
||||
return FALSE;
|
||||
}
|
||||
rv = fputs (conv, stream);
|
||||
g_free (conv);
|
||||
}
|
||||
|
||||
if (rv == EOF) { /* note, apparently, does not set errno */
|
||||
g_printerr ("fputs failed");
|
||||
g_warning ("%s: fputs failed", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -442,6 +443,7 @@ mu_util_fputs_encoded (const char *str, FILE *stream)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static gboolean
|
||||
print_args (FILE *stream, const char *frm, va_list args)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue