BOM parameter

BOM can be not written now if -nobom is passed as parameter.
This commit is contained in:
wforums 2014-09-06 13:16:25 +02:00
parent 324cd84ffe
commit e9f8313f7c
3 changed files with 44 additions and 25 deletions

View File

@ -79,6 +79,8 @@ void init_options (struct ccx_s_options *options)
options->nofontcolor=0; // 1 = don't put <font color> tags options->nofontcolor=0; // 1 = don't put <font color> tags
options->notypesetting=0; // 1 = Don't put <i>, <u>, etc typesetting tags options->notypesetting=0; // 1 = Don't put <i>, <u>, etc typesetting tags
options->no_bom = 0; // Use BOM by default.
options->settings_608.direct_rollup = 0; options->settings_608.direct_rollup = 0;
options->settings_608.no_rollup = 0; options->settings_608.no_rollup = 0;
options->settings_608.force_rollup = 0; options->settings_608.force_rollup = 0;
@ -466,14 +468,19 @@ int main(int argc, char *argv[])
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
break; break;
default: default:
if (ccx_options.encoding==CCX_ENC_UTF_8) // Write BOM if (!ccx_options.no_bom){
if (ccx_options.encoding == CCX_ENC_UTF_8){ // Write BOM
writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout1); writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout1);
if (ccx_options.encoding==CCX_ENC_UNICODE) // Write BOM }
if (ccx_options.encoding == CCX_ENC_UNICODE){ // Write BOM
writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout1); writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout1);
if( init_encoder(enc_ctx,&wbout1) ) }
}
if (init_encoder(enc_ctx, &wbout1)){
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
} }
} }
}
if (ccx_options.extract == 12 && ccx_options.write_format != CCX_OF_RAW) if (ccx_options.extract == 12 && ccx_options.write_format != CCX_OF_RAW)
mprint (" and \n"); mprint (" and \n");
if (ccx_options.extract!=1) if (ccx_options.extract!=1)
@ -517,16 +524,21 @@ int main(int argc, char *argv[])
fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); fatal (EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
break; break;
default: default:
if (ccx_options.encoding==CCX_ENC_UTF_8) // Write BOM if (!ccx_options.no_bom){
if (ccx_options.encoding == CCX_ENC_UTF_8){ // Write BOM
writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout2); writeraw(UTF8_BOM, sizeof(UTF8_BOM), &wbout2);
if (ccx_options.encoding==CCX_ENC_UNICODE) // Write BOM }
if (ccx_options.encoding == CCX_ENC_UNICODE){ // Write BOM
writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout2); writeraw(LITTLE_ENDIAN_BOM, sizeof(LITTLE_ENDIAN_BOM), &wbout2);
if( init_encoder(enc_ctx+1,&wbout2) ) }
}
if (init_encoder(enc_ctx + 1, &wbout2)){
fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n"); fatal(EXIT_NOT_ENOUGH_MEMORY, "Not enough memory\n");
} }
} }
} }
} }
}
if (ccx_options.transcript_settings.xds) if (ccx_options.transcript_settings.xds)
{ {

View File

@ -42,6 +42,8 @@ struct ccx_s_options // Options from user parameters
struct ccx_boundary_time extraction_start, extraction_end; // Segment we actually process struct ccx_boundary_time extraction_start, extraction_end; // Segment we actually process
int print_file_reports; int print_file_reports;
int no_bom; // Set to 1 when no BOM (Byte Order Mark) should be used for files. Note, this might make files unreadable in windows!
ccx_decoder_608_settings settings_608; // Contains the settings for the 608 decoder. ccx_decoder_608_settings settings_608; // Contains the settings for the 608 decoder.
/* subtitle codec type */ /* subtitle codec type */
@ -108,7 +110,6 @@ struct ccx_s_options // Options from user parameters
int line_terminator_lf; // 0 = CRLF, 1=LF int line_terminator_lf; // 0 = CRLF, 1=LF
int noautotimeref; // Do NOT set time automatically? int noautotimeref; // Do NOT set time automatically?
enum ccx_datasource input_source; // Files, stdin or network enum ccx_datasource input_source; // Files, stdin or network
}; };
struct ts_payload struct ts_payload

View File

@ -348,7 +348,7 @@ void usage (void)
mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n"); mprint (" -1, -2, -12: Output Field 1 data, Field 2 data, or both\n");
mprint (" (DEFAULT is -1)\n"); mprint (" (DEFAULT is -1)\n");
mprint (" -cc2: When in srt/sami mode, process captions in channel 2\n"); mprint (" -cc2: When in srt/sami mode, process captions in channel 2\n");
mprint (" instead channel 1.\n"); mprint (" instead of channel 1.\n");
mprint ("-svc --service N,N...: Enabled CEA-708 captions processing for the listed\n"); mprint ("-svc --service N,N...: Enabled CEA-708 captions processing for the listed\n");
mprint (" services. The parameter is a command delimited list\n"); mprint (" services. The parameter is a command delimited list\n");
mprint (" of services numbers, such as \"1,2\" to process the\n"); mprint (" of services numbers, such as \"1,2\" to process the\n");
@ -477,6 +477,8 @@ void usage (void)
mprint (" affects Teletext in timed transcript with -datets.\n"); mprint (" affects Teletext in timed transcript with -datets.\n");
mprint ("\n"); mprint ("\n");
mprint ("Options that affect what kind of output will be produced:\n"); mprint ("Options that affect what kind of output will be produced:\n");
mprint(" -nobom: Do not append a BOM (Byte Order Mark) to output files.");
mprint(" Note that this may break files when using Windows.");
mprint (" -unicode: Encode subtitles in Unicode instead of Latin-1.\n"); mprint (" -unicode: Encode subtitles in Unicode instead of Latin-1.\n");
mprint (" -utf8: Encode subtitles in UTF-8 (no longer needed.\n"); mprint (" -utf8: Encode subtitles in UTF-8 (no longer needed.\n");
mprint (" because UTF-8 is now the default).\n"); mprint (" because UTF-8 is now the default).\n");
@ -863,6 +865,9 @@ void parse_parameters (int argc, char *argv[])
ccx_options.nofontcolor=1; ccx_options.nofontcolor=1;
continue; continue;
} }
if (strcmp(argv[i], "-nobom") == 0){
ccx_options.no_bom = 1;
}
if (strcmp (argv[i],"-nots")==0 || if (strcmp (argv[i],"-nots")==0 ||
strcmp (argv[i],"--notypesetting")==0) strcmp (argv[i],"--notypesetting")==0)
{ {
@ -1425,6 +1430,7 @@ void parse_parameters (int argc, char *argv[])
if (strcmp (argv[i],"-UCLA")==0 || strcmp (argv[i],"-ucla")==0) if (strcmp (argv[i],"-UCLA")==0 || strcmp (argv[i],"-ucla")==0)
{ {
ccx_options.millis_separator='.'; ccx_options.millis_separator='.';
ccx_options.no_bom = 1;
if (!ccx_options.transcript_settings.isFinal){ if (!ccx_options.transcript_settings.isFinal){
ccx_options.transcript_settings.showStartTime = 1; ccx_options.transcript_settings.showStartTime = 1;
ccx_options.transcript_settings.showEndTime = 1; ccx_options.transcript_settings.showEndTime = 1;