Index: subreader.c =================================================================== --- subreader.c (revision 31341) +++ subreader.c (working copy) @@ -116,10 +116,12 @@ static char *s = NULL, *slacktime_s; char text[LINE_LEN+1], *p=NULL, *q; int state; + extern int sub_utf8; current->lines = current->start = current->end = 0; current->alignment = SUB_ALIGNMENT_BOTTOMCENTER; state = 0; + sub_utf8 = 1; /* read the first line */ if (!s) @@ -135,7 +137,9 @@ s = stristr (s, "Start="); if (s) { - current->start = strtol (s + 6, &s, 0) / 10; + s += 6; + if (*s == '"') s++; + current->start = strtol (s, &s, 0) / 10; /* eat '>' */ for (; *s != '>' && *s != '\0'; s++); s++; @@ -161,17 +165,25 @@ case 3: /* get all text until '<' appears */ if (*s == '\0') break; - else if (!strncasecmp (s, "
", 4)) { + else if (!strncasecmp (s, "", 4)) { *p = '\0'; p = text; trail_space (text); if (text[0] != '\0') current->text[current->lines++] = strdup (text); - s += 4; + s = strchr (s, '>'); + if (!s) break; + s++; } else if ((*s == '{') && !sub_no_text_pp) { state = 5; ++s; continue; } else if (*s == '<') { state = 4; } else if (!strncasecmp (s, " ", 6)) { *p++ = ' '; s += 6; } else if (*s == '\t') { *p++ = ' '; s++; } else if (*s == '\r' || *s == '\n') { s++; } + else if (!strncasecmp (s, "&#", 2)) { + uint32_t c = strtol(s+2, &s, 0); + uint8_t tmp; + PUT_UTF8(c, tmp, *p++ = tmp;) + if (*s == ';') s++; } else *p++ = *s++; /* skip duplicated space */