diff -U 3 -r -N icu_original/source/aclocal.m4 icu/source/aclocal.m4
--- icu_original/source/aclocal.m4	2005-07-25 22:10:52.000000000 +0000
+++ icu/source/aclocal.m4	2005-10-23 18:07:58.000000000 +0000
@@ -37,6 +37,9 @@
 	else
 	  	icu_cv_host_frag=mh-cygwin-msvc
 	fi ;;
+*-*-*djgpp)
+	icu_cv_host_frag=mh-djgpp
+	;;
 *-*-mingw32)
 	if test "$GCC" = yes; then
 	  	icu_cv_host_frag=mh-mingw
@@ -318,6 +321,7 @@
   FILE *f=fopen("conftestval", "w");
   if (!f) exit(1);
   fprintf(f, "%d\n", sizeof($1));
+  fclose(f);
   exit(0);
 }], AC_CV_NAME=`cat conftestval`, AC_CV_NAME=0, ifelse([$2], , , AC_CV_NAME=$2))])dnl
 AC_MSG_RESULT($AC_CV_NAME)
diff -U 3 -r -N icu_original/source/common/ustr_wcs.c icu/source/common/ustr_wcs.c
--- icu_original/source/common/ustr_wcs.c	2005-07-10 16:31:30.000000000 +0000
+++ icu/source/common/ustr_wcs.c	2005-10-26 22:22:24.000000000 +0000
@@ -315,7 +315,7 @@
             if(retVal == -1){
                 *pErrorCode = U_ILLEGAL_CHAR_FOUND;
                 goto cleanup;
-            }else if(retVal == cStackCap){
+            }else if(retVal >= (cStackCap-1)){
                 /* Should rarely occur */
                 u_growAnyBufferFromStatic(cStack,(void**)&pCSrc,&cStackCap,
                     cStackCap * _BUFFER_CAPACITY_MULTIPLIER, 0, sizeof(char));
diff -U 3 -r -N icu_original/source/config/Makefile.inc.in icu/source/config/Makefile.inc.in
--- icu_original/source/config/Makefile.inc.in	2005-06-08 00:38:08.000000000 +0000
+++ icu/source/config/Makefile.inc.in	2005-10-31 12:38:20.000000000 +0000
@@ -87,20 +87,19 @@
 #    - $(ICULIBS_I18N)    - i18n library, formatting, etc.
 #    - $(ICULIBS_LAYOUT)  - ICU layout library. 
 #    - $(ICULIBS_ICUIO)   - ICU stdio equivalent library
-
-ICULIBS_COMMON = -l$(ICUPREFIX)uc$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_DATA   = -l$(ICUPREFIX)data$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_I18N   = -l$(ICUPREFIX)i18n$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_TOOLUTIL = -l$(ICUPREFIX)tu$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_COMMON = -l$(ICUPREFIX)$(COMMON_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_DATA   = -l$(ICUPREFIX)$(DATA_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_I18N   = -l$(ICUPREFIX)$(I18N_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_TOOLUTIL = -l$(ICUPREFIX)$(TOOLUTIL_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
 ICULIBS_CTESTFW = -l$(ICUPREFIX)ctestfw$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_ICUIO = -l$(ICUPREFIX)io$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_ICUIO = -l$(ICUPREFIX)$(IO_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
 ICULIBS_OBSOLETE = -l$(ICUPREFIX)obsolete$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_LAYOUT = -l$(ICUPREFIX)le$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
-ICULIBS_LAYOUTEX = -l$(ICUPREFIX)lx$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_LAYOUT = -l$(ICUPREFIX)$(LAYOUT_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
+ICULIBS_LAYOUTEX = -l$(ICUPREFIX)$(LAYOUTEX_STUBNAME)$(ICULIBSUFFIX)$(ICULIBSUFFIX_VERSION)
 ICULIBS_BASE = $(LIBS) -L$(libdir)
 
 # for icu-config to test with
-ICULIBS_COMMON_LIB_NAME = ${LIBICU}uc${ICULIBSUFFIX}${ICULIBSUFFIX_VERSION}.${SO}
+ICULIBS_COMMON_LIB_NAME = ${LIBICU}${COMMON_STUBNAME}${ICULIBSUFFIX}${ICULIBSUFFIX_VERSION}.${SO}
 
 # ICULIBS is the set of libraries your application should link
 # with usually. Many applications will want to add $(ICULIBS_I18N) as well. 
diff -U 3 -r -N icu_original/source/config/icu-config-bottom icu/source/config/icu-config-bottom
--- icu_original/source/config/icu-config-bottom	2004-04-01 07:49:02.000000000 +0000
+++ icu/source/config/icu-config-bottom	2005-10-31 12:24:14.000000000 +0000
@@ -10,8 +10,34 @@
     PKGDATA_MODE=dll
 fi
 
+if [ "x$DATA_STUBNAME" = "x" ]; then
+    DATA_STUBNAME=data
+fi
+if [ "x$COMMON_STUBNAME" = "x" ]; then
+    COMMON_STUBNAME=uc
+fi
+if [ "x$I18N_STUBNAME" = "x" ]; then
+    I18N_STUBNAME=i18n
+fi
+if [ "x$LAYOUT_STUBNAME" = "x" ]; then
+    LAYOUT_STUBNAME=le
+fi
+if [ "x$LAYOUTEX_STUBNAME" = "x" ]; then
+    LAYOUTEX_STUBNAME=lx
+fi
+if [ "x$IO_STUBNAME" = "x" ]; then
+    IO_STUBNAME=io
+fi
+if [ "x$TOOLUTIL_STUBNAME" = "x" ]; then
+    TOOLUTIL_STUBNAME=tu
+fi
+if [ "x$CTESTFW_STUBNAME" = "x" ]; then
+    CTESTFW_STUBNAME=test
+fi
+
 }
 
+
 ## The actual code of icu-config goes here.
 
 ME=`basename $0`
diff -U 3 -r -N icu_original/source/config/mh-djgpp icu/source/config/mh-djgpp
--- icu_original/source/config/mh-djgpp	1970-01-01 00:00:00.000000000 +0000
+++ icu/source/config/mh-djgpp	2005-10-31 11:49:10.000000000 +0000
@@ -0,0 +1,126 @@
+## -*-makefile-*-
+## DJGPP specific setup
+## Copyright (c) 2001-2005, International Business Machines Corporation and
+## others. All Rights Reserved.
+##
+## This platform requires that you the following configure options:
+## --disable-shared --enable-static --with-data-packaging=common
+## --disable-threads
+
+# TODO: Finish the rest of this port. This platform port is incomplete.
+
+# We install sbin tools into the same bin directory because
+# pkgdata needs some of the tools in sbin, and we can't always depend on
+# icu-config working on Windows.
+sbindir=$(bindir)
+
+# This isn't the original 16-bit DOS. The platform has GNU stuff too.
+CPPFLAGS+=-D_POSIX_SOURCE
+
+## Commands to generate dependency files
+GEN_DEPS.c=	$(CC) -E -MM $(DEFS) $(CPPFLAGS)
+GEN_DEPS.cc=	$(CXX) -E -MM $(DEFS) $(CPPFLAGS)
+
+## Flags to create/use a static library
+ifneq ($(ENABLE_SHARED),YES)
+## Make sure that the static libraries can be built and used
+CPPFLAGS += -DU_STATIC_IMPLEMENTATION
+else
+## Make sure that the static libraries can be built
+STATICCPPFLAGS = -DU_STATIC_IMPLEMENTATION
+endif
+
+## Flags for position independent code
+SHAREDLIBCFLAGS = 
+SHAREDLIBCXXFLAGS = 
+SHAREDLIBCPPFLAGS = -DPIC
+
+## Additional flags when building libraries and with threads
+LIBCPPFLAGS = -D_REENTRANT
+THREADSCPPFLAGS = -D_REENTRANT
+
+# Commands to link. Link with C++ in case static libraries are used.
+LINK.c=       $(CXX) $(CXXFLAGS) $(LDFLAGS)
+#LINK.cc=      $(CXX) $(CXXFLAGS) $(LDFLAGS)
+
+## Commands to make a shared library
+SHLIB.c=	$(CC) $(CFLAGS) $(LDFLAGS) -shared
+SHLIB.cc=	$(CXX) $(CXXFLAGS) $(LDFLAGS) -shared
+
+## Compiler switch to embed a runtime search path
+LD_RPATH=	
+LD_RPATH_PRE=	-Wl,-rpath,
+
+## Compiler switch to embed a library name
+LD_SONAME = 
+
+## Shared object suffix
+## --- DJGPP doesn't support shared objects/DLLs so just use the 
+##     static library suffix
+SO = a
+## Non-shared intermediate object suffix
+STATIC_O = ao
+SO_TARGET_VERSION_SUFFIX=
+
+## An import library is needed for z/OS and MSVC
+#IMPORT_LIB_EXT = .lib
+
+# Change the stubnames so that poorly working FAT disks and installation
+# programs can work. This is also for backwards compatibility.
+STATIC_PREFIX_WHEN_USED=
+STATIC_PREFIX=
+DATA_STUBNAME = dt
+I18N_STUBNAME = in
+LIBICU = $(STATIC_PREFIX_WHEN_USED)$(ICUPREFIX)
+
+# The #M# is used to delete lines for icu-config
+# Current full path directory.
+CURR_FULL_DIR=$(shell pwd)#M#
+# Current full path directory for use in source code in a -D compiler option.
+CURR_SRCCODE_FULL_DIR=$(subst /,\\\\,$(shell pwd))#M#
+
+## Compilation rules
+%.$(STATIC_O): $(srcdir)/%.c
+	$(COMPILE.c) $(STATICCPPFLAGS) $(STATICCFLAGS) -o $@ $<
+%.o: $(srcdir)/%.c
+	$(COMPILE.c) $(DYNAMICCPPFLAGS) $(DYNAMICCFLAGS) -o $@ $<
+
+%.$(STATIC_O): $(srcdir)/%.cpp
+	$(COMPILE.cc) $(STATICCPPFLAGS) $(STATICCXXFLAGS) -o $@ $<
+%.o: $(srcdir)/%.cpp
+	$(COMPILE.cc) $(DYNAMICCPPFLAGS) $(DYNAMICCXXFLAGS) -o $@ $<
+
+
+## Dependency rules
+%.d: $(srcdir)/%.c
+	@echo "generating dependency information for $<"
+	@echo -n "$@ " > $@
+	@$(GEN_DEPS.c) $< >> $@ || (rm -f $@ && FALSE)
+
+%.d: $(srcdir)/%.cpp
+	@echo "generating dependency information for $<"
+	@echo -n "$@ " > $@
+	@$(GEN_DEPS.cc) $< >> $@ || (rm -f $@ && FALSE)
+
+## Versioned target for a shared library.
+## Since symbolic links don't work the same way on Windows,
+## we only use the version major number.
+FINAL_SO_TARGET=$(basename $(SO_TARGET))$(SO_TARGET_VERSION_MAJOR).$(SO)
+MIDDLE_SO_TARGET=$(FINAL_SO_TARGET)
+
+## Special pkgdata information that is needed
+PKGDATA_VERSIONING = -r $(SO_TARGET_VERSION_MAJOR)
+#ICUPKGDATA_INSTALL_DIR = $(shell cygpath -dma $(DESTDIR)$(ICUPKGDATA_DIR))#M#
+#ICUPKGDATA_INSTALL_LIBDIR = $(shell cygpath -dma $(DESTDIR)$(libdir))#M#
+
+## Versioned libraries rules
+%.$(SO): %$(SO_TARGET_VERSION_MAJOR).$(SO)
+	@echo -n
+
+# Environment variable to set a runtime search path
+LDLIBRARYPATH_ENVVAR = PATH
+
+# The type of assembly to write for generating an object file
+GENCCODE_ASSEMBLY=-a gcc-cygwin
+
+## End DJGPP specific setup
diff -U 3 -r -N icu_original/source/configure icu/source/configure
--- icu_original/source/configure	2005-07-25 22:10:50.000000000 +0000
+++ icu/source/configure	2005-10-23 18:06:56.000000000 +0000
@@ -1243,7 +1243,7 @@
 echo $ac_n "checking checking for executable suffix""... $ac_c" 1>&6
 echo "configure:1245: checking checking for executable suffix" >&5
 case "${host}" in
-    *-*-cygwin*|*-*-mingw*)  EXEEXT=.exe ;;
+    *-*-cygwin*|*-*-mingw*|*-*-*djgpp)  EXEEXT=.exe ;;
     *)      EXEEXT="" ;;
 esac
 ac_exeext=$EXEEXT
@@ -1529,6 +1529,9 @@
 	else
 	  	icu_cv_host_frag=mh-cygwin-msvc
 	fi ;;
+*-*-*djgpp)
+	icu_cv_host_frag=mh-djgpp
+	;;
 *-*-mingw32)
 	if test "$GCC" = yes; then
 	  	icu_cv_host_frag=mh-mingw
@@ -3792,6 +3795,7 @@
   FILE *f=fopen("conftestval", "w");
   if (!f) exit(1);
   fprintf(f, "%d\n", sizeof(wchar_t));
+  fclose(f);
   exit(0);
 }
 EOF
@@ -4035,6 +4039,7 @@
 	*-*-hpux*) 	platform=U_HPUX ;;
 	*-apple-darwin*|*-apple-rhapsody*)	platform=U_DARWIN ;;
 	*-*-cygwin*|*-*-mingw*)	platform=U_CYGWIN ;;
+	*-*-*djgpp)	platform=U_DOS ;;
 	*-*ibm-openedition*|*-*-os390*)	platform=OS390
 			if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
 				ICUDATA_CHAR="e"
diff -U 3 -r -N icu_original/source/configure.in icu/source/configure.in
--- icu_original/source/configure.in	2005-07-11 21:27:46.000000000 +0000
+++ icu/source/configure.in	2005-10-22 18:08:44.000000000 +0000
@@ -71,7 +71,7 @@
 dnl files, which confuses the AC_EXEEXT macro.
 AC_MSG_CHECKING(checking for executable suffix)
 case "${host}" in
-    *-*-cygwin*|*-*-mingw*)  EXEEXT=.exe ;;
+    *-*-cygwin*|*-*-mingw*|*-*-*djgpp)  EXEEXT=.exe ;;
     *)      EXEEXT="" ;;
 esac
 ac_exeext=$EXEEXT
@@ -915,6 +915,7 @@
 	*-*-hpux*) 	platform=U_HPUX ;;
 	*-apple-darwin*|*-apple-rhapsody*)	platform=U_DARWIN ;;
 	*-*-cygwin*|*-*-mingw*)	platform=U_CYGWIN ;;
+	*-*-*djgpp)	platform=U_DOS ;;
 	*-*ibm-openedition*|*-*-os390*)	platform=OS390
 			if test "${ICU_ENABLE_ASCII_STRINGS}" != "1"; then
 				ICUDATA_CHAR="e"
diff -U 3 -r -N icu_original/source/data/Makefile.in icu/source/data/Makefile.in
--- icu_original/source/data/Makefile.in	2005-06-28 22:32:52.000000000 +0000
+++ icu/source/data/Makefile.in	2005-11-02 12:04:34.000000000 +0000
@@ -144,12 +144,14 @@
 	$(INVOKE) $(BINDIR)/icuswap -t$(ICUDATA_CHAR) $(ICUDATA_ARCHIVE) $(ICUDATA_SOURCE_ARCHIVE)
 endif
 else
+ifneq ($(ENABLE_STATIC),YES)
 ifeq ($(PKGDATA_MODE),common)
 # We have a source data common archive in the native endianess,
 # and it's what we want to build. Try to not run any of ICU's tools.
 ICUDATA_SOURCE_IS_NATIVE_TARGET=YES
 endif
 endif
+endif
 
 # During this INVOKE we only want to use stubdata.
 # We don't want to try to write over files that we are using.
diff -U 3 -r -N icu_original/source/extra/uconv/uconv.cpp icu/source/extra/uconv/uconv.cpp
--- icu_original/source/extra/uconv/uconv.cpp	2005-06-22 03:21:26.000000000 +0000
+++ icu/source/extra/uconv/uconv.cpp	2005-10-23 13:54:30.000000000 +0000
@@ -38,9 +38,11 @@
 
 #include "unicode/uwmsg.h"
 
-#if (defined(U_WINDOWS) || defined(U_CYGWIN)) && !defined(__STRICT_ANSI__)
+#if (defined(U_WINDOWS) || defined(U_CYGWIN) || defined(U_DOS)) && !defined(__STRICT_ANSI__)
+#undef _POSIX_SOURCE
 #include <io.h>
 #include <fcntl.h>
+#define _POSIX_SOURCE
 #define USE_FILENO_BINARY_MODE 1
 #endif
 
diff -U 3 -r -N icu_original/source/runConfigureICU icu/source/runConfigureICU
--- icu_original/source/runConfigureICU	2005-05-18 18:29:00.000000000 +0000
+++ icu/source/runConfigureICU	2005-10-24 09:56:52.000000000 +0000
@@ -35,6 +35,7 @@
     Cygwin              Use the GNU gcc/g++ compilers on Cygwin
     Cygwin/MSVC         Use the Microsoft Visual C++ compiler on Cygwin
     Cygwin/ICL          Use the Intel C++ compiler on Cygwin
+    DJGPP               Use the GNU gcc/g++ compilers on DOS
     FreeBSD             Use the GNU gcc/g++ compilers on Free BSD
     HP-UX/ACC           Use the HP ANSI C/Advanced C++ compilers on HP-UX 11
     Linux               Use the GNU gcc/g++ compilers on Linux
@@ -137,6 +139,15 @@
         CC=`which gcc`; export CC
         CXX=`which g++`; export CXX
         ;;
+    DJGPP)
+        THE_OS=DOS
+        THE_COMP="gcc"
+        CC=`which gcc`; export CC
+        CXX=`which gpp`; export CXX
+        CFLAGS="$CFLAGS -D_POSIX_SOURCE"; export CFLAGS
+        CXXFLAGS="$CXXFLAGS -D_POSIX_SOURCE"; export CXXFLAGS
+        OPTS="$OPTS --disable-shared --enable-static --with-data-packaging=archive --disable-threads"
+        ;;
     Solaris)
         THE_OS=SOLARIS
         THE_COMP="Sun's CC"
diff -U 3 -r -N icu_original/source/test/cintltst/Makefile.in icu/source/test/cintltst/Makefile.in
--- icu_original/source/test/cintltst/Makefile.in	2005-06-16 19:44:30.000000000 +0000
+++ icu/source/test/cintltst/Makefile.in	2005-10-23 21:11:36.000000000 +0000
@@ -29,9 +29,12 @@
 LINK = $(LINK.c)
 endif
 
+PATH_BS:=\\
 BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
 # Simplify the path for Unix
 BUILDDIR := $(BUILDDIR:test/cintltst/../../=)
+# Simplify the path for DOS/Windows
+BUILDDIR := $(subst $(PATH_BS)$(PATH_BS),$(PATH_BS),$(BUILDDIR))
 # Simplify the path for Windows
 BUILDDIR := $(BUILDDIR:test\\cintltst/../../=)
 # Simplify the path for Windows 98
diff -U 3 -r -N icu_original/source/test/cintltst/udatatst.c icu/source/test/cintltst/udatatst.c
--- icu_original/source/test/cintltst/udatatst.c	2005-07-19 17:45:36.000000000 +0000
+++ icu/source/test/cintltst/udatatst.c	2005-10-23 11:35:32.000000000 +0000
@@ -358,7 +358,7 @@
 
     log_verbose("Testing udata_setAppData() with %s\n", filePath);
 
-#if defined(U_WINDOWS) || defined(U_CYGWIN)
+#if defined(U_WINDOWS) || defined(U_CYGWIN) || defined(U_DOS)
     fileHandle = open( filePath, O_RDONLY | O_BINARY );
 #else
     fileHandle = open( filePath, O_RDONLY);
diff -U 3 -r -N icu_original/source/test/intltest/Makefile.in icu/source/test/intltest/Makefile.in
--- icu_original/source/test/intltest/Makefile.in	2005-07-12 21:33:16.000000000 +0000
+++ icu/source/test/intltest/Makefile.in	2005-10-23 21:12:30.000000000 +0000
@@ -19,9 +19,12 @@
 ## Target information
 TARGET = intltest$(EXEEXT)
 
+PATH_BS:=\\
 BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
 # Simplify the path for Unix
 BUILDDIR := $(BUILDDIR:test/intltest/../../=)
+# Simplify the path for DOS/Windows
+BUILDDIR := $(subst $(PATH_BS)$(PATH_BS),$(PATH_BS),$(BUILDDIR))
 # Simplify the path for Windows
 BUILDDIR := $(BUILDDIR:test\\intltest/../../=)
 # Simplify the path for Windows 98
diff -U 3 -r -N icu_original/source/test/iotest/Makefile.in icu/source/test/iotest/Makefile.in
--- icu_original/source/test/iotest/Makefile.in	2005-06-23 08:10:52.000000000 +0000
+++ icu/source/test/iotest/Makefile.in	2005-10-23 21:13:02.000000000 +0000
@@ -19,9 +19,12 @@
 ## Target information
 TARGET = iotest$(EXEEXT)
 
+PATH_BS:=\\
 BUILDDIR := $(CURR_SRCCODE_FULL_DIR)/../../
 # Simplify the path for Unix
 BUILDDIR := $(BUILDDIR:test/iotest/../../=)
+# Simplify the path for DOS/Windows
+BUILDDIR := $(subst $(PATH_BS)$(PATH_BS),$(PATH_BS),$(BUILDDIR))
 # Simplify the path for Windows
 BUILDDIR := $(BUILDDIR:test\\iotest/../../=)
 # Simplify the path for Windows 98
diff -U 3 -r -N icu_original/source/test/iotest/iotest.cpp icu/source/test/iotest/iotest.cpp
--- icu_original/source/test/iotest/iotest.cpp	2005-07-14 07:03:34.000000000 +0000
+++ icu/source/test/iotest/iotest.cpp	2005-10-23 11:36:48.000000000 +0000
@@ -28,7 +28,7 @@
 
 #if U_IOSTREAM_SOURCE >= 199711
 #include <iostream>
-#if defined(U_LINUX) || defined(U_CYGWIN)
+#if defined(U_LINUX) || defined(U_CYGWIN) || defined(U_DOS)
 #define USE_SSTREAM 1
 #include <sstream>
 #else
@@ -45,7 +45,7 @@
 #include <stdlib.h>
 
 U_CDECL_BEGIN
-#ifdef U_WINDOWS
+#if defined(U_WINDOWS)
 const UChar NEW_LINE[] = {0x0d,0x0a,0};
 const char C_NEW_LINE[] = {0x0d,0x0a,0};
 #define UTF8_NEW_LINE "\x0d\x0a"
diff -U 3 -r -N icu_original/source/tools/genrb/derb.c icu/source/tools/genrb/derb.c
--- icu_original/source/tools/genrb/derb.c	2005-03-15 06:06:12.000000000 +0000
+++ icu/source/tools/genrb/derb.c	2005-10-23 12:19:28.000000000 +0000
@@ -30,7 +30,7 @@
 #include <stdio.h>
 #include <ctype.h>
 
-#if defined(U_WINDOWS) || defined(U_CYGWIN)
+#if defined(U_WINDOWS) || defined(U_CYGWIN) || defined(U_DOS)
 #include <io.h>
 #include <fcntl.h>
 #endif
@@ -289,6 +289,11 @@
                     fprintf(stderr, "%s: couldn't set standard output to binary mode\n", pname);
                     return 4;
                 }
+#elif defined(U_DOS)
+                if (setmode(fileno(out), O_BINARY) == -1) {
+                    fprintf(stderr, "%s: couldn't set standard output to binary mode\n", pname);
+                    return 4;
+                }
 #endif
             } else {
                 char thefile[4096], *tp;
