From 5f68a9166f47741c6e0a1a544a0d5c31d6104760 Mon Sep 17 00:00:00 2001 From: cfsmp3 Date: Sat, 11 Oct 2014 10:39:56 +0200 Subject: [PATCH] -Added -bom --- docs/CHANGES.TXT | 4 ++++ src/lib_ccx/ccx_common_option.c | 2 ++ src/lib_ccx/params.c | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index 5b704690..01170619 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -1,6 +1,10 @@ 0.75 ----------- - CCExtractor can be used as library if compiled using cmake +- By default the Windows version adds BOM to generated UTF files (this is + because it's needed to open the files correctly) while all other + builds don't add it (because it messes with text processing tools). + You can use -bom and -nobom to change the behaviour. 0.74 ----------- diff --git a/src/lib_ccx/ccx_common_option.c b/src/lib_ccx/ccx_common_option.c index aa7e1b68..6f37a06d 100644 --- a/src/lib_ccx/ccx_common_option.c +++ b/src/lib_ccx/ccx_common_option.c @@ -6,8 +6,10 @@ void init_options (struct ccx_s_options *options) { #ifdef _WIN32 options->buffer_input = 1; // In Windows buffering seems to help + options->no_bom = 0; #else options->buffer_input = 0; // In linux, not so much. + options->no_bom = 1; #endif options->nofontcolor=0; // 1 = don't put tags options->notypesetting=0; // 1 = Don't put , , etc typesetting tags diff --git a/src/lib_ccx/params.c b/src/lib_ccx/params.c index 72d18f73..b476d9b7 100644 --- a/src/lib_ccx/params.c +++ b/src/lib_ccx/params.c @@ -477,8 +477,13 @@ void usage (void) mprint (" affects Teletext in timed transcript with -datets.\n"); mprint ("\n"); mprint ("Options that affect what kind of output will be produced:\n"); + mprint(" -bom: Append a BOM (Byte Order Mark) to output files."); + mprint(" Note that most text processing tools in linux will not"); + mprint(" like BOM."); + mprint(" This is the default in Windows builds."); mprint(" -nobom: Do not append a BOM (Byte Order Mark) to output files."); mprint(" Note that this may break files when using Windows."); + mprint(" This is the default in non-Windows builds."); mprint (" -unicode: Encode subtitles in Unicode instead of Latin-1.\n"); mprint (" -utf8: Encode subtitles in UTF-8 (no longer needed.\n"); mprint (" because UTF-8 is now the default).\n"); @@ -865,8 +870,13 @@ void parse_parameters (struct ccx_s_options *opt, int argc, char *argv[]) ccx_options.nofontcolor=1; continue; } + if (strcmp(argv[i], "-bom") == 0){ + ccx_options.no_bom = 0; + continue; + } if (strcmp(argv[i], "-nobom") == 0){ ccx_options.no_bom = 1; + continue; } if (strcmp (argv[i],"-nots")==0 || strcmp (argv[i],"--notypesetting")==0)