# HG changeset patch # User eugeni # Date 1212086117 0 # Node ID 32ab01bb3404b8d56b4c4657769fe3f1bd5afbc4 # Parent c2fffa420e973050854526286ad945853991e5f9 Clear iconv conversion state after each subtitle line. This fixes a bug when the last character on a subtitle line is sometimes moved to the beginning of the next line. Patch by Guy Shapiro, bugs sguy org. diff -r c2fffa420e97 -r 32ab01bb3404 subreader.c --- a/subreader.c Thu May 29 12:56:44 2008 +0000 +++ b/subreader.c Thu May 29 18:35:17 2008 +0000 @@ -1133,6 +1133,11 @@ free(ot); continue; } + // In some stateful encodings, we must clear the state to handle the last character + if (iconv(icdsc, NULL, NULL, + &op, &oleft) == (size_t)(-1)) { + mp_msg(MSGT_SUBREADER,MSGL_WARN,"SUB: error recoding line, can't clear encoding state.\n"); + } *op='\0' ; free (sub->text[l]); sub->text[l] = ot;