changeset 26889:32ab01bb3404

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.
author eugeni
date Thu, 29 May 2008 18:35:17 +0000
parents c2fffa420e97
children 80bf10a56b7e
files subreader.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;