From f5a8ce6408d5f33c387a93a0d4f7881edcdc2ce6 Mon Sep 17 00:00:00 2001 From: eugeni Date: Thu, 29 May 2008 18:35:17 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26921 b3059339-0415-0410-9bf9-f77b7e298cf2 --- subreader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subreader.c b/subreader.c index dd9c7d2c31..5561639c6a 100644 --- a/subreader.c +++ b/subreader.c @@ -1133,6 +1133,11 @@ subtitle* subcp_recode (subtitle *sub) 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;