diff options
Diffstat (limited to 'unix2dos.c')
-rw-r--r-- | unix2dos.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -276,8 +276,8 @@ int ConvertUnixToDos(FILE* ipInF, FILE* ipOutF, CFlag *ipFlag, char *progname) switch (ipFlag->ConvMode) { case CONVMODE_ASCII: /* ascii */ - case CONVMODE_UTF16LE: /* Assume UTF-16LE */ - case CONVMODE_UTF16BE: /* Assume UTF-16BE */ + case CONVMODE_UTF16LE: /* Assume UTF-16LE, bomtype = FILE_UTF8 */ + case CONVMODE_UTF16BE: /* Assume UTF-16BE, bomtype = FILE_UTF8 */ ConvTable = U2DAsciiTable; break; case CONVMODE_7BIT: /* 7bit */ @@ -606,7 +606,7 @@ int ConvertUnixToDosNewFile(char *ipInFN, char *ipOutFN, CFlag *ipFlag, char *pr #endif #endif - if ((ipFlag->add_bom) || (ipFlag->bomtype > 0)) + if ((ipFlag->add_bom) || ((ipFlag->keep_bom) && (ipFlag->bomtype > 0))) fprintf(TempF, "%s", "\xEF\xBB\xBF"); /* UTF-8 BOM */ /* Turn off ISO and 7-bit conversion for Unicode text files */ @@ -838,7 +838,7 @@ int ConvertUnixToDosStdio(CFlag *ipFlag, char *progname) ipFlag->bomtype = FILE_UTF16BE; #endif - if ((ipFlag->add_bom) || (ipFlag->bomtype > 0)) + if ((ipFlag->add_bom) || ((ipFlag->keep_bom) && (ipFlag->bomtype > 0))) fprintf(stdout, "%s", "\xEF\xBB\xBF"); /* UTF-8 BOM */ #ifdef D2U_UNICODE @@ -923,6 +923,7 @@ int main (int argc, char *argv[]) pFlag->bomtype = FILE_MBS; #endif pFlag->add_bom = 0; + pFlag->keep_bom = 1; if ( ((ptr=strrchr(argv[0],'/')) == NULL) && ((ptr=strrchr(argv[0],'\\')) == NULL) ) ptr = argv[0]; @@ -948,6 +949,8 @@ int main (int argc, char *argv[]) PrintUsage(progname); return(pFlag->error); } + else if ((strcmp(argv[ArgIdx],"-b") == 0) || (strcmp(argv[ArgIdx],"--keep-bom") == 0)) + pFlag->keep_bom = 1; else if ((strcmp(argv[ArgIdx],"-k") == 0) || (strcmp(argv[ArgIdx],"--keepdate") == 0)) pFlag->KeepDate = 1; else if ((strcmp(argv[ArgIdx],"-f") == 0) || (strcmp(argv[ArgIdx],"--force") == 0)) @@ -960,6 +963,11 @@ int main (int argc, char *argv[]) pFlag->NewLine = 1; else if ((strcmp(argv[ArgIdx],"-m") == 0) || (strcmp(argv[ArgIdx],"--add-bom") == 0)) pFlag->add_bom = 1; + else if ((strcmp(argv[ArgIdx],"-r") == 0) || (strcmp(argv[ArgIdx],"--remove-bom") == 0)) + { + pFlag->keep_bom = 0; + pFlag->add_bom = 0; + } else if ((strcmp(argv[ArgIdx],"-S") == 0) || (strcmp(argv[ArgIdx],"--skip-symlink") == 0)) pFlag->Follow = SYMLINK_SKIP; else if ((strcmp(argv[ArgIdx],"-F") == 0) || (strcmp(argv[ArgIdx],"--follow-symlink") == 0)) |