diff --git a/src/minimodem.1.in b/src/minimodem.1.in index f9257f5..4d8d7e6 100644 --- a/src/minimodem.1.in +++ b/src/minimodem.1.in @@ -136,6 +136,11 @@ The bits are printed in the order they are received. Framing bits (start and stop bits) are omitted from the output. (This option applies to \-\-rx mode only). .TP +.B \-\-print-filter +Filter the received text output, replacing any "non-printable" bytes +with a '.' character. +(This option applies to \-\-rx mode only). +.TP .B \-\-benchmarks Run and report internal performance tests (all other flags are ignored). .TP diff --git a/src/minimodem.c b/src/minimodem.c index 02aeb2c..9e5699c 100644 --- a/src/minimodem.c +++ b/src/minimodem.c @@ -21,6 +21,7 @@ #include +#include #include #include #include @@ -311,6 +312,7 @@ usage() " --rx-one\n" " --benchmarks\n" " --binary-output\n" + " --print-filter\n" " {baudmode}\n" " any_number_N Bell-like N bps --ascii\n" " 1200 Bell202 1200 bps --ascii\n" @@ -327,6 +329,7 @@ main( int argc, char*argv[] ) char *modem_mode = NULL; int TX_mode = -1; int quiet_mode = 0; + int output_print_filter = 0; float band_width = 0; unsigned int bfsk_mark_f = 0; unsigned int bfsk_space_f = 0; @@ -397,6 +400,7 @@ main( int argc, char*argv[] ) MINIMODEM_OPT_RX_ONE, MINIMODEM_OPT_BENCHMARKS, MINIMODEM_OPT_BINARY_OUTPUT, + MINIMODEM_OPT_PRINT_FILTER, MINIMODEM_OPT_XRXNOISE, }; @@ -431,6 +435,7 @@ main( int argc, char*argv[] ) { "rx-one", 0, 0, MINIMODEM_OPT_RX_ONE }, { "benchmarks", 0, 0, MINIMODEM_OPT_BENCHMARKS }, { "binary-output", 0, 0, MINIMODEM_OPT_BINARY_OUTPUT }, + { "print-filter", 0, 0, MINIMODEM_OPT_PRINT_FILTER }, { "Xrxnoise", 1, 0, MINIMODEM_OPT_XRXNOISE }, { 0 } }; @@ -537,6 +542,9 @@ main( int argc, char*argv[] ) case MINIMODEM_OPT_BINARY_OUTPUT: output_mode_binary = 1; break; + case MINIMODEM_OPT_PRINT_FILTER: + output_print_filter = 1; + break; case MINIMODEM_OPT_XRXNOISE: rxnoise_factor = atof(optarg); break; @@ -1148,16 +1156,22 @@ main( int argc, char*argv[] ) dataout_size - dataout_nbytes, bits, (int)bfsk_n_data_bits); + if ( dataout_nbytes == 0 ) + continue; + /* * Print the output buffer to stdout */ - if ( dataout_nbytes ) { + if ( output_print_filter == 0 ) { + if ( write(1, dataoutbuf, dataout_nbytes) < 0 ) + perror("write"); + } else { char *p = dataoutbuf; for ( ; dataout_nbytes; p++,dataout_nbytes-- ) { char printable_char = isprint(*p)||isspace(*p) ? *p : '.'; - printf( "%c", printable_char ); + if ( write(1, &printable_char, 1) < 0 ) + perror("write"); } - fflush(stdout); } } /* end of the main loop */ diff --git a/tests/test-60-multibyte b/tests/test-60-multibyte new file mode 100755 index 0000000..d4414cf --- /dev/null +++ b/tests/test-60-multibyte @@ -0,0 +1 @@ +exec ./self-test testdata-multibyte.txt 1200 diff --git a/tests/testdata-multibyte.txt b/tests/testdata-multibyte.txt new file mode 100644 index 0000000..c67556f --- /dev/null +++ b/tests/testdata-multibyte.txt @@ -0,0 +1,4 @@ +Minimodem unterstützt jetzt Deutsch! +Beachten sie, dass wörter mit multibyte-zeichen korrekt gedruckt werden. +Minimodem ahora soporta Español! +Minimodem prend désormais en Français!