Mercurial > mplayer.hg
changeset 19366:614f445786af
Reuse UTF-8 reading code in libavutil
author | reimar |
---|---|
date | Sat, 12 Aug 2006 15:28:01 +0000 |
parents | 544753ed7cec |
children | c4601b2c3d5c |
files | libvo/sub.c |
diffstat | 1 files changed, 3 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/libvo/sub.c Sat Aug 12 12:12:31 2006 +0000 +++ b/libvo/sub.c Sat Aug 12 15:28:01 2006 +0000 @@ -14,6 +14,7 @@ #include "font_load.h" #include "sub.h" #include "spudec.h" +#include "libavutil/common.h" #define NEW_SPLITTING @@ -142,23 +143,8 @@ unsigned utf8_get_char(char **str) { uint8_t *strp = (uint8_t *)*str; - unsigned c = *strp++; - unsigned mask = 0x80; - int len = -1; - while (c & mask) { - mask >>= 1; - len++; - } - if (len <= 0 || len > 4) - goto no_utf8; - c &= mask - 1; - while ((*strp & 0xc0) == 0x80) { - if (len-- <= 0) - goto no_utf8; - c = (c << 6) | (*strp++ & 0x3f); - } - if (len) - goto no_utf8; + unsigned c; + GET_UTF8(c, *strp++, goto no_utf8;); *str = (char *)strp; return c;