| 453 | } |
| 454 | |
| 455 | static int convert_to_utf8(struct mailinfo *mi, |
| 456 | struct strbuf *line, const char *charset) |
| 457 | { |
| 458 | char *out; |
| 459 | size_t out_len; |
| 460 | |
| 461 | if (!mi->metainfo_charset || !charset || !*charset) |
| 462 | return 0; |
| 463 | |
| 464 | if (same_encoding(mi->metainfo_charset, charset)) |
| 465 | return 0; |
| 466 | out = reencode_string_len(line->buf, line->len, |
| 467 | mi->metainfo_charset, charset, &out_len); |
| 468 | if (!out) { |
| 469 | mi->input_error = -1; |
| 470 | return error("cannot convert from %s to %s", |
| 471 | charset, mi->metainfo_charset); |
| 472 | } |
| 473 | strbuf_attach(line, out, out_len, out_len + 1); |
| 474 | return 0; |
| 475 | } |
| 476 | |
| 477 | static void decode_header(struct mailinfo *mi, struct strbuf *it) |
| 478 | { |
no test coverage detected