Mercurial > mplayer.hg
changeset 23424:7286d245bf33
Move code for reading a file and recoding it to utf-8 to a separate function.
author | eugeni |
---|---|
date | Fri, 01 Jun 2007 19:56:44 +0000 |
parents | 6b18c979dd45 |
children | 098e38f17263 |
files | libass/ass.c libass/ass.h |
diffstat | 2 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libass/ass.c Fri Jun 01 17:29:35 2007 +0000 +++ b/libass/ass.c Fri Jun 01 19:56:44 2007 +0000 @@ -982,17 +982,9 @@ return track; } -/** - * \brief Read subtitles from file. - * \param library libass library object - * \param fname file name - * \param codepage recode buffer contents from given codepage - * \return newly allocated track -*/ -ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage) +char* read_file_recode(char* fname, char* codepage, int* size) { char* buf; - ass_track_t* track; size_t bufsize; buf = read_file(fname, &bufsize); @@ -1007,6 +999,26 @@ if (!buf) return 0; #endif + *size = bufsize; + return buf; +} + +/** + * \brief Read subtitles from file. + * \param library libass library object + * \param fname file name + * \param codepage recode buffer contents from given codepage + * \return newly allocated track +*/ +ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage) +{ + char* buf; + ass_track_t* track; + size_t bufsize; + + buf = read_file_recode(fname, codepage, &bufsize); + if (!buf) + return 0; track = parse_memory(library, buf); free(buf); if (!track)
--- a/libass/ass.h Fri Jun 01 17:29:35 2007 +0000 +++ b/libass/ass.h Fri Jun 01 19:56:44 2007 +0000 @@ -162,6 +162,8 @@ */ void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration); +char* read_file_recode(char* fname, char* codepage, int* size); + /** * \brief Read subtitles from file. * \param fname file name