Upgrade to libiconv-1.3.
diff --git a/ChangeLog b/ChangeLog
index 88d4289..180be0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,72 @@
+2000-04-15  Bruno Haible  <haible@clisp.cons.org>
+
+        * Version 1.3 released.
+        * include/iconv.h.in (_LIBICONV_VERSION), README, windows/iconv.rc:
+          Bump version number.
+        * src/Makefile.in (LIBICONV_VERSION_INFO): Define to 2:0:0.
+
+2000-04-15  Bruno Haible  <haible@clisp.cons.org>
+
+        * THANKS: New file.
+        * INSTALL.generic: New file.
+
+        Implement and document UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE.
+        * src/ucs2be.h, src/ucs2le.h, src/ucs4be.h, src/ucs4le.h: New files.
+        * src/converters.h: Include them.
+        * src/ucs2swapped.h: Remove #defines for UCS-2-BE, UCS-2-LE.
+        * src/ucs4swapped.h: Remove #defines for UCS-4-BE, UCS-4-LE.
+        * src/encodings.def (UCS-2BE): Renamed from UCS-2-BE.
+          (UCS-2LE): Renamed from UCS-2-LE.
+          (UCS-4BE): Renamed from UCS-4-BE.
+          (UCS-4LE): Renamed from UCS-4-LE.
+        * Makefile.devel (src/aliases.h): Pass option "-i 1" to gperf.
+        * README, man/iconv_open.3: Add UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE.
+        * tests/Makefile.in (check): Check UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE.
+        * tests/Makefile.msvc (check): Likewise.
+        * tests/UCS-*snippet*: New files.
+
+        Allow building as a shared library on Windows.
+        Allow running the tests on Windows.
+        * Makefile.devel (include/iconv.h.msvc): Remove rule.
+          (include/iconv.h.msvc-static, include/iconv.h.msvc-shared): New
+          rules.
+          (all): Update.
+        * windows/dllexport.h: New file.
+        * include/iconv.h.msvc: Remove file.
+        * include/iconv.h.msvc-static, include/iconv.h.msvc-shared: New
+          autogenerated files.
+        * Makefile.msvc (STATIC, DEBUG): Default to 0.
+          (all): Choose either include\iconv.h.msvc-static or
+          include\iconv.h.msvc-shared.
+          (check): Depend on all.
+          (all, check, mostlyclean, clean, distclean, maintainer-clean):
+          Recurse into tests directory.
+        * src/Makefile.msvc (STATIC, DEBUG): Default to 0.
+          (WARN_CFLAGS, PICFLAGS, OPTIMFLAGS): New variables.
+          (CFLAGS): Use them. Add -MD and -DBUILDING_LIBICONV.
+          (RESOURCES): New variable.
+          (iconv.lib): Change rule when building DLL.
+          (clean, distclean): One filename per line.
+        * tests/Makefile.msvc: New file.
+        * tests/check-stateful.bat, tests/check-stateless.bat,
+          tests/check-translit.bat: New files.
+        * tests/uniq-u.c: New file, taken from GNU textutils.
+        * README.win32: Update.
+        Based on patches by Taro Muraoka <koron@tka.att.ne.jp>.
+
+2000-04-14  Bruno Haible  <haible@clisp.cons.org>
+
+        Fix an OSF/1 problem.
+        * configure.in: Define GCC variable for substitution.
+        * src/Makefile.in (libiconv_plug_osf.so): Change rule if not using
+          gcc.
+
+2000-04-13  Bruno Haible  <haible@clisp.cons.org>
+
+        Fix a SunOS 4 problem.
+        * include/iconv.h.in: If EILSEQ is not defined by the system, define
+          it to ENOENT, not EILSEQ.
+
 2000-04-02  Bruno Haible  <haible@clisp.cons.org>
 
         Allow building on filesystems lacking symlinks and hard links.
@@ -15,12 +84,12 @@
 
 2000-03-14  Bruno Haible  <haible@clisp.cons.org>
 
-        Implement and document UTF-16BE and UTF16-LE.
+        Implement and document UTF-16BE and UTF16LE.
         * src/utf16be.h, src/utf16le.h: New files.
         * src/converters.h: Include them.
-        * src/encodings.def (UTF-16BE, UTF16-LE): New encodings.
-        * README, man/iconv_open.3: Add UTF-16BE, UTF16-LE.
-        * tests/Makefile.in (check): Check UTF-16, UTF-16BE, UTF16-LE.
+        * src/encodings.def (UTF-16BE, UTF16LE): New encodings.
+        * README, man/iconv_open.3: Add UTF-16BE, UTF16LE.
+        * tests/Makefile.in (check): Check UTF-16, UTF-16BE, UTF16LE.
         * tests/UTF-16*snippet*: New files.
 
         * src/utf16.h (utf16_wctomb): Output a byte order mark.
diff --git a/INSTALL.generic b/INSTALL.generic
new file mode 100644
index 0000000..50dbe43
--- /dev/null
+++ b/INSTALL.generic
@@ -0,0 +1,183 @@
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/Makefile.devel b/Makefile.devel
index c97c5d3..53ee5a2 100644
--- a/Makefile.devel
+++ b/Makefile.devel
@@ -10,12 +10,13 @@
 RM = rm -f
 
 
-all : configures src/config.h.msvc include/iconv.h.msvc src/aliases.h src/aliases_aix.h src/flags.h src/translit.h
+all : configures src/config.h.msvc include/iconv.h.msvc-static include/iconv.h.msvc-shared src/aliases.h src/aliases_aix.h src/flags.h src/translit.h
 
 
 # Before making a new release:
 # - check that the encoding lists in README and man/iconv_open.3 are up to date,
-# - increment the version number in include/iconv.h.in and README,
+# - increment the version number in include/iconv.h.in and README
+#   and windows/iconv.rc,
 # - update the version info in src/Makefile.in,
 # - do "make -f Makefile.devel".
 
@@ -45,14 +46,17 @@
 src/config.h.msvc : src/config.h.in
 	sed -e 's/#undef WORDS_LITTLEENDIAN$$/#define WORDS_LITTLEENDIAN 1/' < $< > $@
 
-include/iconv.h.msvc : include/iconv.h.in
+include/iconv.h.msvc-static : include/iconv.h.in
 	sed -e 's/@ICONV_CONST@/const/g' < $< > $@
 
+include/iconv.h.msvc-shared : include/iconv.h.in windows/dllexport.h
+	sed -e 's/@ICONV_CONST@/const/g' -e 's/extern \([^"]\)/extern LIBICONV_DLL_EXPORTED \1/' -e '/_LIBICONV_VERSION/r windows/dllexport.h' < $< > $@
+
 
 # We use "-7" to make a smaller table, but use "unsigned char" array indices
 # to avoid gcc warning.
 src/aliases.h : src/aliases.gperf
-	$(GPERF) -t -L ANSI-C -H aliases_hash -N aliases_lookup -7 -C -k '1,3-11,$$' src/aliases.gperf | sed -e 's/\[str/\[(unsigned char) str/' > tmp.h
+	$(GPERF) -t -L ANSI-C -H aliases_hash -N aliases_lookup -7 -C -k '1,3-11,$$' -i 1 src/aliases.gperf | sed -e 's/\[str/\[(unsigned char) str/' > tmp.h
 	$(CP) tmp.h src/aliases.h
 	$(RM) tmp.h
 
diff --git a/Makefile.msvc b/Makefile.msvc
index 0268036..55cf56b 100644
--- a/Makefile.msvc
+++ b/Makefile.msvc
@@ -2,6 +2,19 @@
 
 #### Start of system configuration section. ####
 
+# Flags that can be set on the nmake command line:
+#   STATIC=1  for compiling a static .lib (default is a .dll with a stub .lib)
+#   DEBUG=1   for compiling with debugging information
+# Note that nmake command line flags are automatically passed to subdirectory
+# Makefiles. Therefore we don't need to pass them explicitly to subdirectory
+# Makefiles, but the subdirectory Makefiles need to have the same defaults.
+!if !defined(STATIC)
+STATIC=0
+!endif
+!if !defined(DEBUG)
+DEBUG=0
+!endif
+
 # Directories used by "make install":
 prefix = /usr/local
 local_prefix = /usr/local
@@ -19,13 +32,20 @@
 SHELL = /bin/sh
 
 all : force
-	$(LN) include\iconv.h.msvc include\iconv.h
+!if $(STATIC)
+	$(LN) include\iconv.h.msvc-static include\iconv.h
+!else
+	$(LN) include\iconv.h.msvc-shared include\iconv.h
+!endif
 	cd src
 	$(MAKE) -f Makefile.msvc all
 	cd ..
 #	cd man
 #	$(MAKE) -f Makefile.msvc all
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc all
+	cd ..
 
 install : force
 	cd src; $(MAKE) -r install prefix='$(prefix)' exec_prefix='$(exec_prefix)' libdir='$(libdir)'
@@ -47,13 +67,16 @@
 	$(RM) $(includedir)/iconv.h
 	cd man; $(MAKE) -r uninstall prefix='$(prefix)' exec_prefix='$(exec_prefix)' mandir='$(mandir)'
 
-check : force
+check : all
 	cd src
 	$(MAKE) -f Makefile.msvc check
 	cd ..
 #	cd man
 #	$(MAKE) -f Makefile.msvc check
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc check
+	cd ..
 
 mostlyclean : force
 	cd src
@@ -62,6 +85,9 @@
 #	cd man
 #	$(MAKE) -f Makefile.msvc mostlyclean
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc mostlyclean
+	cd ..
 
 clean : force
 	cd src
@@ -70,6 +96,9 @@
 #	cd man
 #	$(MAKE) -f Makefile.msvc clean
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc clean
+	cd ..
 
 distclean : force
 	cd src
@@ -78,6 +107,9 @@
 #	cd man
 #	$(MAKE) -f Makefile.msvc distclean
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc distclean
+	cd ..
 	$(RM) config.status config.log config.cache Makefile
 	$(RM) include\iconv.h
 
@@ -88,6 +120,9 @@
 #	cd man
 #	$(MAKE) -f Makefile.msvc maintainer-clean
 #	cd ..
+	cd tests
+	$(MAKE) -f Makefile.msvc maintainer-clean
+	cd ..
 	$(RM) config.status config.log config.cache Makefile
 	$(RM) include\iconv.h
 
diff --git a/NEWS b/NEWS
index a2f2829..29e2777 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,11 @@
+New in 1.3:
+* Added UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE converters.
+* Fixed the definition of EILSEQ on SunOS4.
+* Fixed a build problem on OSF/1.
+* Support for building as a shared library on Win32.
+
 New in 1.2:
-* Added UTF-16BE and UTF16-LE converters.
+* Added UTF-16BE and UTF16LE converters.
 * Changed the UTF-16 encoder.
 * Fixed the treatment of tab characters in the UTF-7 converter.
 * Fixed an internal error when output buffer was not large enough.
diff --git a/NOTES b/NOTES
index a702942..b8c45a4 100644
--- a/NOTES
+++ b/NOTES
@@ -269,6 +269,11 @@
    Full Unicode
      * UTF-8, UCS-2, UCS-4
        We implement these. Obviously.
+     * UCS-2BE, UCS-2LE, UCS-4BE, UCS-4LE
+       We implement these because they are the preferred internal
+       representation of strings in Unicode aware applications. These are
+       non-ambiguous names, known to glibc. (glibc doesn't have
+       UCS-2-INTERNAL and UCS-4-INTERNAL.)
      * UTF-16, UTF-16BE, UTF-16LE
        We implement these, because UTF-16 is still the favourite encoding of
        the president of the Unicode Consortium (for political reasons), and
diff --git a/PORTS b/PORTS
index 9e2e60e..83802f7 100644
--- a/PORTS
+++ b/PORTS
@@ -25,9 +25,16 @@
 * AIX 4.2:
   OK
 
+* SunOS 4:
+  OK when configured --enable-static --disable-shared
+  (gcc cannot create shared libraries without relocations)
+
 * FreeBSD 3.3:
   OK
 
+* BeOS 5:
+  OK
+
 * Win32 with MSVC 4.0:
   OK
 
diff --git a/README b/README
index 58eeffa..facc865 100644
--- a/README
+++ b/README
@@ -33,7 +33,12 @@
     Platform specifics
         HP-ROMAN8, NEXTSTEP
     Full Unicode
-        UTF-8, UCS-2, UCS-4, UTF-16, UTF-16BE, UTF-16LE, UTF-7, JAVA
+        UTF-8
+        UCS-2, UCS-2BE, UCS-2LE
+        UCS-4, UCS-4BE, UCS-4LE
+        UTF-16, UTF-16BE, UTF-16LE
+        UTF-7
+        JAVA
     Full Unicode, in terms of `uint16_t' or `uint32_t'
         (with machine dependent endianness and alignment)
         UCS-2-INTERNAL, UCS-4-INTERNAL
@@ -79,7 +84,7 @@
 
 
 Distribution:
-    ftp://ftp.ilog.fr/pub/Users/haible/gnu/libiconv-1.1.tar.gz
+    ftp://ftp.ilog.fr/pub/Users/haible/gnu/libiconv-1.3.tar.gz
 
 Homepage:
     http://clisp.cons.org/~haible/packages-libiconv.html
diff --git a/README.win32 b/README.win32
index 5f0a6b1..cdf9e7f 100644
--- a/README.win32
+++ b/README.win32
@@ -4,18 +4,36 @@
 want to create it as a shared library (DLL), you are on your own; patches
 are welcome.
 
-- Requires MS Visual C/C++ 4.0 or 5.0.
+- Requires MS Visual C/C++ 4.0 or 5.0 or 6.0.
 
 - Cannot build in a separate directory.
 
 - Build instructions:
 
-   Make sure that the MSVC4.0 or MSVC5.0 utilities ("cl" etc.) are found in
-   PATH.
+   Make sure that the MSVC4.0 or MSVC5.0 or MSVC6.0 utilities ("cl" etc.) are
+   found in PATH.
+
+   For shared library (DLL):
 
         nmake -f Makefile.msvc
+   or
+        nmake -f Makefile.msvc check               [This runs the testsuite.]
+
+   For static library:
+
+        nmake -f Makefile.msvc STATIC=1
+   or
+        nmake -f Makefile.msvc STATIC=1 check      [This runs the testsuite.]
+
+   If you want to build both the shared and static library, you have to
+   unpack the libiconv sources twice in different directories. Don't mix
+   the two formats; you cannot use the iconv.h generated for the static
+   library together with the shared library or vice versa.
 
 - Installation:
 
-   Copy include/libiconv.h to your header file repository, under the
-   name 'iconv.h'. Copy src/iconv.lib to your library repository.
+   Copy include/iconv.h to your header file repository.
+   Copy src/iconv.lib to your library repository.
+   If you built for shared library, also copy src/iconv.dll into one of the
+   directories listed in your PATH, or into the directory containing the
+   executable which shall make use of libiconv.
diff --git a/THANKS b/THANKS
new file mode 100644
index 0000000..6e8242e
--- /dev/null
+++ b/THANKS
@@ -0,0 +1,6 @@
+          Thanks to                               for
+
+Edmund Grimley Evans  <edmundo@rano.org>      bug reports
+
+Taro Muraoka  <koron@tka.att.ne.jp>           Win32 DLL support
+
diff --git a/configure b/configure
index 0fc2377..9b324bd 100755
--- a/configure
+++ b/configure
@@ -1700,6 +1700,7 @@
 esac
 if test -n "$OS"; then
   
+  
   PLUGLIB="libiconv_plug.so"
 else
   PLUGLIB=""
@@ -1863,6 +1864,7 @@
 s%@LIBICONV@%$LIBICONV%g
 s%@ICONV_CONST@%$ICONV_CONST%g
 s%@OS@%$OS%g
+s%@GCC@%$GCC%g
 s%@PLUGLIB@%$PLUGLIB%g
 
 CEOF
diff --git a/configure.in b/configure.in
index d08b329..e215108 100644
--- a/configure.in
+++ b/configure.in
@@ -73,6 +73,7 @@
 esac
 if test -n "$OS"; then
   AC_SUBST(OS)
+  AC_SUBST(GCC)
   PLUGLIB="libiconv_plug.so"
 else
   PLUGLIB=""
diff --git a/include/iconv.h.in b/include/iconv.h.in
index ec59fa0..610afa2 100644
--- a/include/iconv.h.in
+++ b/include/iconv.h.in
@@ -21,7 +21,7 @@
 #ifndef _LIBICONV_H
 #define _LIBICONV_H
 
-#define _LIBICONV_VERSION 0x0102    /* version number: (major<<8) + minor */
+#define _LIBICONV_VERSION 0x0103    /* version number: (major<<8) + minor */
 
 /* We would like to #include any system header file which could define
    iconv_t, 1. in order to eliminate the risk that the user gets compilation
@@ -50,8 +50,11 @@
 
 /* Get errno declaration and values. */
 #include <errno.h>
+/* Some systems, like SunOS 4, don't have EILSEQ. On these systems, define
+   EILSEQ ourselves, but don't define it as EINVAL, because iconv() callers
+   want to distinguish EINVAL and EILSEQ. */
 #ifndef EILSEQ
-#define EILSEQ EINVAL
+#define EILSEQ ENOENT
 #endif
 
 
diff --git a/include/iconv.h.msvc b/include/iconv.h.msvc-shared
similarity index 80%
copy from include/iconv.h.msvc
copy to include/iconv.h.msvc-shared
index 6f49d45..34ffcb1 100644
--- a/include/iconv.h.msvc
+++ b/include/iconv.h.msvc-shared
@@ -21,7 +21,13 @@
 #ifndef _LIBICONV_H
 #define _LIBICONV_H
 
-#define _LIBICONV_VERSION 0x0102    /* version number: (major<<8) + minor */
+#define _LIBICONV_VERSION 0x0103    /* version number: (major<<8) + minor */
+
+#ifdef BUILDING_LIBICONV
+#define LIBICONV_DLL_EXPORTED __declspec(dllexport)
+#else
+#define LIBICONV_DLL_EXPORTED __declspec(dllimport)
+#endif
 
 /* We would like to #include any system header file which could define
    iconv_t, 1. in order to eliminate the risk that the user gets compilation
@@ -50,8 +56,11 @@
 
 /* Get errno declaration and values. */
 #include <errno.h>
+/* Some systems, like SunOS 4, don't have EILSEQ. On these systems, define
+   EILSEQ ourselves, but don't define it as EINVAL, because iconv() callers
+   want to distinguish EINVAL and EILSEQ. */
 #ifndef EILSEQ
-#define EILSEQ EINVAL
+#define EILSEQ ENOENT
 #endif
 
 
@@ -65,7 +74,7 @@
 #ifndef LIBICONV_PLUG
 #define iconv_open libiconv_open
 #endif
-extern iconv_t iconv_open (const char* tocode, const char* fromcode);
+extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode);
 
 /* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes
    starting at `*inbuf', writing at most `*outbytesleft' bytes starting at
@@ -75,13 +84,13 @@
 #ifndef LIBICONV_PLUG
 #define iconv libiconv
 #endif
-extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
+extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
 
 /* Frees resources allocated for conversion descriptor `cd'. */
 #ifndef LIBICONV_PLUG
 #define iconv_close libiconv_close
 #endif
-extern int iconv_close (iconv_t cd);
+extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd);
 
 
 #ifndef LIBICONV_PLUG
@@ -90,7 +99,7 @@
 
 /* Control of attributes. */
 #define iconvctl libiconvctl
-extern int iconvctl (iconv_t cd, int request, void* argument);
+extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument);
 
 /* Requests for iconvctl. */
 #define ICONV_TRIVIALP            0  /* int *argument */
diff --git a/include/iconv.h.msvc b/include/iconv.h.msvc-static
similarity index 92%
rename from include/iconv.h.msvc
rename to include/iconv.h.msvc-static
index 6f49d45..9f1834e 100644
--- a/include/iconv.h.msvc
+++ b/include/iconv.h.msvc-static
@@ -21,7 +21,7 @@
 #ifndef _LIBICONV_H
 #define _LIBICONV_H
 
-#define _LIBICONV_VERSION 0x0102    /* version number: (major<<8) + minor */
+#define _LIBICONV_VERSION 0x0103    /* version number: (major<<8) + minor */
 
 /* We would like to #include any system header file which could define
    iconv_t, 1. in order to eliminate the risk that the user gets compilation
@@ -50,8 +50,11 @@
 
 /* Get errno declaration and values. */
 #include <errno.h>
+/* Some systems, like SunOS 4, don't have EILSEQ. On these systems, define
+   EILSEQ ourselves, but don't define it as EINVAL, because iconv() callers
+   want to distinguish EINVAL and EILSEQ. */
 #ifndef EILSEQ
-#define EILSEQ EINVAL
+#define EILSEQ ENOENT
 #endif
 
 
diff --git a/man/iconv_open.3 b/man/iconv_open.3
index 3c796ac..70e6e78 100644
--- a/man/iconv_open.3
+++ b/man/iconv_open.3
@@ -9,7 +9,7 @@
 .\"   GNU glibc-2 source code and manual
 .\"   OpenGroup's Single Unix specification http://www.UNIX-systems.org/online.html
 .\"
-.TH ICONV_OPEN 3  "March 14, 2000" "GNU" "Linux Programmer's Manual"
+.TH ICONV_OPEN 3  "April 13, 2000" "GNU" "Linux Programmer's Manual"
 .SH NAME
 iconv_open \- allocate descriptor for character set conversion
 .SH SYNOPSIS
@@ -66,7 +66,14 @@
 HP-ROMAN8, NEXTSTEP
 .TP
 Full Unicode
-UTF-8, UCS-2, UCS-4, UTF-16, UTF-16BE, UTF-16LE, UTF-7, JAVA
+.nf
+UTF-8
+UCS-2, UCS-2BE, UCS-2LE
+UCS-4, UCS-4BE, UCS-4LE
+UTF-16, UTF-16BE, UTF-16LE
+UTF-7
+JAVA
+.fi
 .TP
 Full Unicode, in terms of \fBuint16_t\fP or \fBuint32_t\fP
 (with machine dependent endianness and alignment)
diff --git a/src/Makefile.in b/src/Makefile.in
index 7b3c041..91038f1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -38,7 +38,7 @@
 
 # Before making a release, change this according to the libtool documentation,
 # section "Library interface versions".
-LIBICONV_VERSION_INFO = 1:0:1
+LIBICONV_VERSION_INFO = 2:0:0
 
 # Needed by $(LIBTOOL).
 top_builddir = ..
@@ -65,7 +65,12 @@
 	$(CC) $(CFLAGS) $(INCLUDES) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(PLUG_SOURCES) -G -o libiconv_plug_solaris.so
 
 libiconv_plug_osf.so : $(SOURCES)
-	$(CC) $(CFLAGS) $(INCLUDES) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(PLUG_SOURCES) -shared -o libiconv_plug_osf.so
+	if test -n "@GCC@"; then \
+	  $(CC) $(CFLAGS) $(INCLUDES) -fPIC -DPIC -DLIBICONV_PLUG $(SOURCES) $(PLUG_SOURCES) -shared -o libiconv_plug_osf.so; \
+	else \
+	  $(CC) $(CFLAGS) $(INCLUDES) -DPIC -DLIBICONV_PLUG $(SOURCES) $(PLUG_SOURCES) -c -o iconv_plug.o; \
+	  /bin/ld -shared -expect_unresolved \* -o libiconv_plug_osf.so iconv_plug.o; \
+	fi
 
 iconv.lo : $(srcdir)/iconv.c $(srcdir)/converters.h $(srcdir)/encodings.def $(srcdir)/encodings_aix.def $(srcdir)/aliases.h $(srcdir)/aliases_aix.h $(srcdir)/flags.h
 	$(LIBTOOL_COMPILE) $(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/iconv.c
diff --git a/src/Makefile.msvc b/src/Makefile.msvc
index 4c5b2a3..9fab544 100644
--- a/src/Makefile.msvc
+++ b/src/Makefile.msvc
@@ -2,6 +2,16 @@
 
 #### Start of system configuration section. ####
 
+# Flags that can be set on the nmake command line:
+#   STATIC=1  for compiling a static .lib (default is a .dll with a stub .lib)
+#   DEBUG=1   for compiling with debugging information
+!if !defined(STATIC)
+STATIC=0
+!endif
+!if !defined(DEBUG)
+DEBUG=0
+!endif
+
 # Directories used by "make":
 srcdir = .
 
@@ -12,12 +22,39 @@
 libdir = $(exec_prefix)/lib
 
 # Programs used by "make":
+
 CC = cl
-CFLAGS = -O1
+
+# Set to -W3 if you want to see maximum amount of warnings, including stupid
+# ones. Set to -W1 to avoid warnings about signed/unsigned combinations.
+WARN_CFLAGS = -W1
+
+!if $(STATIC)
+PICFLAGS =
+!else
+# "-GD" (msvc5) optimizes for DLL.
+# mscv4 doesn't know about this flag and ignores it.
+PICFLAGS = -GD
+!endif
+
+!if $(DEBUG)
+OPTIMFLAGS = -Od -Z7
+!else
+# Some people prefer -O2 -G6 instead of -O1, but -O2 is not reliable in MSVC5.
+OPTIMFLAGS = -D_NDEBUG -O1
+!endif
+
+# -MD: use MSVCRT.DLL for C runtime library.
+# -DBUILDING_LIBICONV: Change expansion of LIBICONV_DLL_EXPORTED macro.
+CFLAGS = -MD $(WARN_CFLAGS) $(PICFLAGS) $(OPTIMFLAGS) -DBUILDING_LIBICONV
+
 CPP = cl -E
+
 INCLUDES = -I. -I$(srcdir) -I../include -I$(srcdir)/../include
+
 AR = lib
 AR_FLAGS = /out:
+
 LN = copy
 RM = del
 
@@ -34,6 +71,10 @@
 
 OBJECTS = iconv.obj
 
+# Set to iconv.res in order to include the resources information.
+RESOURCES =
+# RESOURCES = iconv.res
+
 all : iconv.lib
 
 config.h : config.h.msvc
@@ -43,19 +84,37 @@
 iconv.obj : $(srcdir)/iconv.c $(srcdir)/encodings.def $(srcdir)/aliases.h config.h
 	$(CC) $(CFLAGS) $(INCLUDES) -c $(srcdir)/iconv.c
 
+!if $(STATIC)
+
 iconv.lib : $(OBJECTS)
 	$(RM) iconv.lib
 	$(AR) $(AR_FLAGS)iconv.lib $(OBJECTS)
 
+!else
+
+# iconv.dll and iconv.lib are created together.
+iconv.lib : $(OBJECTS) $(RESOURCES)
+	$(CC) -MD -LD $(OBJECTS) $(RESOURCES)
+
+iconv.res : $(srcdir)/../windows/iconv.rc
+	rc -Fo iconv.res $(srcdir)/../windows/iconv.rc
+
+!endif
+
 check : all
 
 mostlyclean : clean
 
 clean : force
-	$(RM) *.obj *.lib core
+	$(RM) *.obj
+	$(RM) *.lib
+	$(RM) *.exp
+	$(RM) *.dll
+	$(RM) iconv.res
+	$(RM) core
 
 distclean : clean
-	$(RM) config.status config.log config.cache Makefile config.h
+	$(RM) config.h
 
 maintainer-clean : distclean
 
diff --git a/src/aliases.gperf b/src/aliases.gperf
index d030437..da23cfe 100644
--- a/src/aliases.gperf
+++ b/src/aliases.gperf
@@ -14,9 +14,17 @@
 UCS-2, ei_ucs2
 ISO-10646-UCS-2, ei_ucs2
 CSUNICODE, ei_ucs2
+UCS-2BE, ei_ucs2be
+UNICODEBIG, ei_ucs2be
+UNICODE-1-1, ei_ucs2be
+CSUNICODE11, ei_ucs2be
+UCS-2LE, ei_ucs2le
+UNICODELITTLE, ei_ucs2le
 UCS-4, ei_ucs4
 ISO-10646-UCS-4, ei_ucs4
 CSUCS4, ei_ucs4
+UCS-4BE, ei_ucs4be
+UCS-4LE, ei_ucs4le
 UTF-16, ei_utf16
 UTF-16BE, ei_utf16be
 UTF-16LE, ei_utf16le
@@ -25,16 +33,8 @@
 CSUNICODE11UTF7, ei_utf7
 UCS-2-INTERNAL, ei_ucs2internal
 UCS-2-SWAPPED, ei_ucs2swapped
-UCS-2-BE, ei_ucs2be
-UNICODEBIG, ei_ucs2be
-UNICODE-1-1, ei_ucs2be
-CSUNICODE11, ei_ucs2be
-UCS-2-LE, ei_ucs2le
-UNICODELITTLE, ei_ucs2le
 UCS-4-INTERNAL, ei_ucs4internal
 UCS-4-SWAPPED, ei_ucs4swapped
-UCS-4-BE, ei_ucs4be
-UCS-4-LE, ei_ucs4le
 JAVA, ei_java
 ISO-8859-1, ei_iso8859_1
 ISO_8859-1, ei_iso8859_1
diff --git a/src/aliases.h b/src/aliases.h
index fd4ab4c..9260627 100644
--- a/src/aliases.h
+++ b/src/aliases.h
@@ -1,13 +1,13 @@
 /* ANSI-C code produced by gperf version 2.7 */
-/* Command-line: gperf -t -L ANSI-C -H aliases_hash -N aliases_lookup -7 -C -k 1,3-11,$ src/aliases.gperf  */
+/* Command-line: gperf -t -L ANSI-C -H aliases_hash -N aliases_lookup -7 -C -k 1,3-11,$ -i 1 src/aliases.gperf  */
 struct alias { const char* name; unsigned int encoding_index; };
 
 #define TOTAL_KEYWORDS 293
 #define MIN_WORD_LENGTH 2
 #define MAX_WORD_LENGTH 45
-#define MIN_HASH_VALUE 4
-#define MAX_HASH_VALUE 2362
-/* maximum key range = 2359, duplicates = 0 */
+#define MIN_HASH_VALUE 8
+#define MAX_HASH_VALUE 2145
+/* maximum key range = 2138, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -17,19 +17,19 @@
 {
   static const unsigned short asso_values[] =
     {
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363,    0,   15, 2363,   45,  230,
-        75,  460,  510,   25,   35,  455,    0,  115,  160, 2363,
-      2363, 2363, 2363, 2363, 2363,  406,  115,  290,  200,    0,
-        65,  295,  100,    0,    5,  358,   40,   60,   15,    0,
-        10, 2363,   60,    0,    0,  180,   40,    0,   90,   10,
-         0, 2363, 2363, 2363, 2363,  340, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363,
-      2363, 2363, 2363, 2363, 2363, 2363, 2363, 2363
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146,    1,   56, 2146,   41,   56,
+        26,  246,  426,  106,   86,  231,    1,  491,   16, 2146,
+      2146, 2146, 2146, 2146, 2146,   21,  231,  241,   39,    1,
+        91,  106,   76,    1,  111,   21,  418,   16,    6,    1,
+         6, 2146,   14,    1,    1,  346,  146,    1,  346,   16,
+         1, 2146, 2146, 2146, 2146,  492, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146,
+      2146, 2146, 2146, 2146, 2146, 2146, 2146, 2146
     };
   register int hval = len;
 
@@ -70,657 +70,644 @@
 {
   static const struct alias wordlist[] =
     {
-      {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"SJIS", ei_sjis},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""},
-      {"JP", ei_iso646_jp},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"L8", ei_iso8859_14},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"LATIN8", ei_iso8859_14},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"R8", ei_hp_roman8},
-      {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"MS-EE", ei_cp1250},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""},
-      {"L5", ei_iso8859_9},
-      {""}, {""}, {""}, {""}, {""},
-      {"866", ei_cp866},
-      {"TCVN", ei_tcvn},
-      {""}, {""},
-      {"L6", ei_iso8859_10},
-      {""},
-      {"SHIFT-JIS", ei_sjis},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"850", ei_cp850},
-      {"ISO-IR-58", ei_gb2312},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"HZ", ei_hz},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"LATIN5", ei_iso8859_9},
-      {""}, {""}, {""}, {""}, {""},
-      {"L2", ei_iso8859_2},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"LATIN6", ei_iso8859_10},
-      {""},
-      {"NEXTSTEP", ei_nextstep},
-      {""}, {""}, {""}, {""},
-      {"ISO-IR-6", ei_ascii},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"ISO-8859-8", ei_iso8859_8},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"IBM866", ei_cp866},
-      {""}, {""}, {""}, {""}, {""},
-      {"JIS0208", ei_jisx0208},
-      {""}, {""}, {""},
-      {"IBM850", ei_cp850},
-      {"US", ei_ascii},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-8859-5", ei_iso8859_5},
-      {""}, {""}, {""}, {""}, {""},
-      {"TIS620", ei_tis620},
-      {"TIS-620", ei_tis620},
-      {""}, {""}, {""},
-      {"LATIN2", ei_iso8859_2},
-      {""}, {""}, {""},
-      {"X0208", ei_jisx0208},
-      {""}, {""}, {""}, {""},
-      {"ISO-8859-6", ei_iso8859_6},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"UTF-8", ei_utf8},
-      {""}, {""},
-      {"TIS620-0", ei_tis620},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"L1", ei_iso8859_1},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"HEBREW", ei_iso8859_8},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-226", ei_iso8859_16},
-      {""}, {""}, {""}, {""},
-      {"EUCTW", ei_euc_tw},
-      {"EUC-TW", ei_euc_tw},
-      {""}, {""}, {""},
-      {"ISO-8859-2", ei_iso8859_2},
-      {""}, {""},
-      {"UCS-2-LE", ei_ucs2le},
-      {""}, {""},
-      {"ISO-2022-JP", ei_iso2022_jp},
-      {"CN", ei_iso646_cn},
-      {""}, {""}, {""}, {""},
-      {"CHINESE", ei_gb2312},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"EUCJP", ei_euc_jp},
-      {"EUC-JP", ei_euc_jp},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"UCS-2", ei_ucs2},
-      {"VISCII", ei_viscii},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-2022-JP-2", ei_iso2022_jp2},
-      {""}, {""}, {""}, {""},
-      {"UCS-2-BE", ei_ucs2be},
-      {""},
-      {"ISO-8859-9", ei_iso8859_9},
-      {""}, {""}, {""},
-      {"UCS-2-INTERNAL", ei_ucs2internal},
-      {"ISO-IR-165", ei_isoir165},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""},
-      {"CP866", ei_cp866},
-      {""},
-      {"MS-HEBR", ei_cp1255},
-      {""}, {""},
-      {"ISO-IR-166", ei_tis620},
-      {""}, {""}, {""}, {""},
-      {"CP850", ei_cp850},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"SHIFT_JIS", ei_sjis},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"ISO-8859-15", ei_iso8859_15},
-      {""}, {""}, {""},
-      {"ISO-IR-100", ei_iso8859_1},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-126", ei_iso8859_7},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO-8859-16", ei_iso8859_16},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""},
-      {"BIG5", ei_ces_big5},
-      {"BIG-5", ei_ces_big5},
-      {""}, {""}, {""}, {""},
-      {"CSSHIFTJIS", ei_sjis},
-      {"ISO-8859-10", ei_iso8859_10},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"MS-ANSI", ei_cp1252},
       {""}, {""}, {""},
       {"KOI8-R", ei_koi8_r},
-      {""}, {""}, {""},
-      {"MS-ANSI", ei_cp1252},
-      {""},
-      {"ISO_8859-8", ei_iso8859_8},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"L7", ei_iso8859_13},
-      {""}, {""}, {""}, {""},
-      {"L3", ei_iso8859_3},
-      {""}, {""}, {""}, {""},
-      {"MS-CYRL", ei_cp1251},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"LATIN1", ei_iso8859_1},
-      {"BIGFIVE", ei_ces_big5},
-      {"BIG-FIVE", ei_ces_big5},
-      {""},
-      {"CP950", ei_cp950},
-      {"IBM819", ei_iso8859_1},
-      {""},
-      {"ISO-2022-JP-1", ei_iso2022_jp1},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ELOT_928", ei_iso8859_7},
-      {""},
-      {"ISO_8859-5", ei_iso8859_5},
       {""}, {""}, {""}, {""}, {""}, {""},
       {"ROMAN8", ei_hp_roman8},
-      {""}, {""},
-      {"X0212", ei_jisx0212},
-      {"UTF-16", ei_utf16},
-      {"L4", ei_iso8859_4},
-      {""}, {""},
-      {"ISO-IR-159", ei_jisx0212},
-      {""},
-      {"WINDOWS-1258", ei_cp1258},
-      {"UTF-16LE", ei_utf16le},
-      {""},
-      {"ISO_8859-6", ei_iso8859_6},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"MACINTOSH", ei_mac_roman},
-      {"ISO-IR-109", ei_iso8859_3},
-      {""}, {""},
-      {"CSIBM866", ei_cp866},
+      {"KOREAN", ei_ksc5601},
       {""}, {""}, {""},
-      {"WINDOWS-1255", ei_cp1255},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-2022-CN-EXT", ei_iso2022_cn_ext},
-      {""},
-      {"WINDOWS-1256", ei_cp1256},
-      {""}, {""}, {""},
-      {"CSISO2022JP", ei_iso2022_jp},
-      {""}, {""}, {""}, {""},
-      {"ISO-2022-CN", ei_iso2022_cn},
-      {"WINDOWS-1250", ei_cp1250},
+      {"HZ", ei_hz},
       {""}, {""}, {""}, {""}, {""}, {""},
-      {"JIS_X0208", ei_jisx0208},
-      {"ISO-8859-1", ei_iso8859_1},
-      {""}, {""}, {""},
-      {"ISO646-JP", ei_iso646_jp},
-      {"EUCCN", ei_euc_cn},
-      {"EUC-CN", ei_euc_cn},
-      {""}, {""}, {""},
-      {"ISO-IR-110", ei_iso8859_4},
+      {"850", ei_cp850},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""},
-      {"CP1258", ei_cp1258},
-      {""},
-      {"CSVISCII", ei_viscii},
-      {""}, {""}, {""},
-      {"WINDOWS-1252", ei_cp1252},
-      {"UTF-16BE", ei_utf16be},
-      {"MACHEBREW", ei_mac_hebrew},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-2", ei_iso8859_2},
-      {""}, {""},
-      {"MAC", ei_mac_roman},
-      {""},
-      {"ISO-IR-199", ei_iso8859_14},
-      {""}, {""}, {""}, {""},
+      {"JP", ei_iso646_jp},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-58", ei_gb2312},
+      {"GREEK8", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"HP-ROMAN8", ei_hp_roman8},
       {""}, {""}, {""}, {""},
-      {"ISO_8859-8:1988", ei_iso8859_8},
+      {"GBK", ei_ces_gbk},
       {""}, {""}, {""},
-      {"GREEK8", ei_iso8859_7},
-      {""}, {""},
-      {"CSISO2022JP2", ei_iso2022_jp2},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""},
-      {"X0201", ei_jisx0201},
-      {"CP1255", ei_cp1255},
-      {""}, {""}, {""},
-      {"ISO_8859-5:1988", ei_iso8859_5},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"CP1256", ei_cp1256},
-      {""}, {""}, {""}, {""},
-      {"ASCII", ei_ascii},
-      {""},
-      {"TIS620.2529-1", ei_tis620},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""},
-      {"CP1250", ei_cp1250},
-      {""}, {""}, {""},
-      {"ISO_8859-9", ei_iso8859_9},
-      {""}, {""},
-      {"UNICODELITTLE", ei_ucs2le},
-      {"KOI8-U", ei_koi8_u},
+      {"GREEK", ei_iso8859_7},
       {""}, {""}, {""}, {""}, {""},
-      {"CSISO159JISX02121990", ei_jisx0212},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"UCS-4-LE", ei_ucs4le},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"JOHAB", ei_johab},
-      {""}, {""}, {""}, {""},
-      {"ISO_8859-15:1998", ei_iso8859_15},
-      {""}, {""}, {""},
-      {"CP819", ei_iso8859_1},
-      {"CSBIG5", ei_ces_big5},
-      {"CN-BIG5", ei_ces_big5},
+      {"ECMA-118", ei_iso8859_7},
       {""},
+      {"TCVN", ei_tcvn},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""},
+      {"866", ei_cp866},
+      {""}, {""}, {""}, {""}, {""}, {""},
       {"ISO-2022-KR", ei_iso2022_kr},
-      {"ISO-IR-138", ei_iso8859_8},
+      {""}, {""}, {""}, {""}, {""},
+      {"MS-GREEK", ei_cp1253},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-6", ei_ascii},
       {""}, {""},
-      {"UHC", ei_cp949},
+      {"TIS620", ei_tis620},
+      {""},
+      {"TIS-620", ei_tis620},
+      {""}, {""}, {""},
+      {"ISO-IR-100", ei_iso8859_1},
+      {""}, {""}, {""},
+      {"IBM850", ei_cp850},
+      {""}, {""}, {""}, {""}, {""},
+      {"SHIFT-JIS", ei_sjis},
+      {""}, {""}, {""}, {""},
+      {"ISO-IR-110", ei_iso8859_4},
+      {""}, {""}, {""}, {""}, {""},
+      {"JIS0208", ei_jisx0208},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-101", ei_iso8859_2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"TIS620-0", ei_tis620},
+      {""}, {""},
+      {"CN", ei_iso646_cn},
+      {"EUCTW", ei_euc_tw},
+      {"WINDOWS-1258", ei_cp1258},
+      {"EUC-TW", ei_euc_tw},
+      {"ISO-IR-226", ei_iso8859_16},
+      {""}, {""}, {""},
+      {"ISO-2022-JP", ei_iso2022_jp},
+      {""},
+      {"CHINESE", ei_gb2312},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+      {"ASCII", ei_ascii},
+      {""}, {""}, {""}, {""},
+      {"GEORGIAN-PS", ei_georgian_ps},
+      {"WINDOWS-1252", ei_cp1252},
+      {""}, {""},
+      {"ISO-2022-JP-2", ei_iso2022_jp2},
+      {""}, {""},
+      {"IBM866", ei_cp866},
+      {"ISO-IR-126", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"WINDOWS-1250", ei_cp1250},
       {""},
       {"ARMSCII-8", ei_armscii_8},
-      {"WINBALTRIM", ei_cp1257},
-      {"CSEUCTW", ei_euc_tw},
-      {""},
-      {"ISO646-US", ei_ascii},
-      {""},
-      {"ISO_8859-15", ei_iso8859_15},
-      {""},
+      {""}, {""},
       {"EUCKR", ei_euc_kr},
+      {""},
       {"EUC-KR", ei_euc_kr},
+      {""},
       {"CSKOI8R", ei_koi8_r},
-      {"CP1252", ei_cp1252},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"KOI8-RU", ei_koi8_ru},
-      {""},
-      {"WINDOWS-1251", ei_cp1251},
-      {""}, {""}, {""},
-      {"ISO_8859-16", ei_iso8859_16},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CN-GB-ISOIR165", ei_isoir165},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-101", ei_iso8859_2},
-      {"ISO_8859-16:2000", ei_iso8859_16},
-      {""}, {""}, {""},
-      {"ISO-IR-148", ei_iso8859_9},
-      {"ISO_8859-10", ei_iso8859_10},
-      {"CSISOLATIN5", ei_iso8859_9},
-      {"UCS-4-BE", ei_ucs4be},
-      {""}, {""}, {""}, {""}, {""},
-      {"UCS-4-INTERNAL", ei_ucs4internal},
-      {"CN-GB", ei_euc_cn},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""},
-      {"CSISOLATIN6", ei_iso8859_10},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"ISO_8859-10:1992", ei_iso8859_10},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSISO87JISX0208", ei_jisx0208},
-      {""}, {""}, {""}, {""},
-      {"KOREAN", ei_ksc5601},
       {"JAVA", ei_java},
-      {""},
-      {"MACTHAI", ei_mac_thai},
-      {""}, {""}, {""},
-      {"CSISOLATINHEBREW", ei_iso8859_8},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"JISX0201-1976", ei_jisx0201},
-      {"US-ASCII", ei_ascii},
-      {"ISO_8859-9:1989", ei_iso8859_9},
-      {""}, {""}, {""},
-      {"JIS_X0208-1990", ei_jisx0208},
-      {""},
-      {"CSISO2022CN", ei_iso2022_cn},
       {""}, {""},
-      {"UCS-2-SWAPPED", ei_ucs2swapped},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO646-CN", ei_iso646_cn},
+      {"WINDOWS-1251", ei_cp1251},
       {""}, {""},
-      {"CSISOLATIN2", ei_iso8859_2},
-      {""},
-      {"MACROMAN", ei_mac_roman},
+      {"ISO-2022-JP-1", ei_iso2022_jp1},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"TCVN-5712", ei_tcvn},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ECMA-118", ei_iso8859_7},
-      {""}, {""}, {""}, {""}, {""},
-      {"CP936", ei_ces_gbk},
-      {""}, {""}, {""},
-      {"JIS_X0212", ei_jisx0212},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-1", ei_iso8859_1},
-      {"CSHPROMAN8", ei_hp_roman8},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""},
-      {"LATIN7", ei_iso8859_13},
       {""}, {""},
       {"ASMO-708", ei_iso8859_6},
-      {""}, {""}, {""}, {""},
-      {"ISO-IR-87", ei_jisx0208},
-      {""},
-      {"LATIN3", ei_iso8859_3},
-      {""}, {""},
-      {"CSUNICODE", ei_ucs2},
-      {"ISO-IR-179", ei_iso8859_13},
       {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSASCII", ei_ascii},
-      {""},
-      {"EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", ei_euc_jp},
+      {"MACROMAN", ei_mac_roman},
+      {"HEBREW", ei_iso8859_8},
+      {""}, {""},
+      {"ISO-IR-138", ei_iso8859_8},
+      {""}, {""},
+      {"WINDOWS-1256", ei_cp1256},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-166", ei_tis620},
+      {""}, {""}, {""}, {""}, {""},
+      {"US", ei_ascii},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"WINDOWS-1255", ei_cp1255},
       {""}, {""}, {""},
-      {"CSPC850MULTILINGUAL", ei_cp850},
+      {"MS-HEBR", ei_cp1255},
+      {""}, {""}, {""},
+      {"MACTHAI", ei_mac_thai},
+      {""}, {""}, {""},
+      {"MACROMANIA", ei_mac_romania},
+      {""},
+      {"EUCJP", ei_euc_jp},
+      {""},
+      {"EUC-JP", ei_euc_jp},
+      {""}, {""}, {""},
+      {"NEXTSTEP", ei_nextstep},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-165", ei_isoir165},
+      {""}, {""},
+      {"ISO-2022-CN-EXT", ei_iso2022_cn_ext},
+      {"ISO-2022-CN", ei_iso2022_cn},
+      {""}, {""}, {""}, {""}, {""},
+      {"CSHPROMAN8", ei_hp_roman8},
+      {""}, {""}, {""},
+      {"VISCII", ei_viscii},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"UCS-2", ei_ucs2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""},
+      {"X0208", ei_jisx0208},
+      {"L8", ei_iso8859_14},
+      {""},
+      {"CSISO2022KR", ei_iso2022_kr},
+      {""}, {""}, {""},
+      {"MS-TURK", ei_cp1254},
+      {"MACINTOSH", ei_mac_roman},
+      {"MACGREEK", ei_mac_greek},
+      {""}, {""}, {""}, {""},
+      {"LATIN8", ei_iso8859_14},
+      {"CP850", ei_cp850},
+      {""},
+      {"CP1258", ei_cp1258},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"UTF-8", ei_utf8},
+      {"L2", ei_iso8859_2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"UCS-2-SWAPPED", ei_ucs2swapped},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"L1", ei_iso8859_1},
+      {""}, {""}, {""}, {""},
+      {"WINDOWS-1257", ei_cp1257},
+      {""}, {""},
+      {"LATIN2", ei_iso8859_2},
+      {"X0212", ei_jisx0212},
+      {""},
+      {"CP1252", ei_cp1252},
+      {""}, {""}, {""},
+      {"ISO-IR-87", ei_jisx0208},
+      {"GB2312", ei_euc_cn},
+      {""}, {""}, {""},
+      {"WINDOWS-1253", ei_cp1253},
+      {"CSISO2022JP", ei_iso2022_jp},
+      {""}, {""},
+      {"EUCCN", ei_euc_cn},
+      {"MAC", ei_mac_roman},
+      {"EUC-CN", ei_euc_cn},
+      {""}, {""},
+      {"CP866", ei_cp866},
+      {"L6", ei_iso8859_10},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-148", ei_iso8859_9},
+      {"CSASCII", ei_ascii},
+      {""}, {""},
+      {"CP1250", ei_cp1250},
+      {"CSISO2022JP2", ei_iso2022_jp2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"L5", ei_iso8859_9},
+      {""}, {""}, {""},
+      {"X0201", ei_jisx0201},
+      {""}, {""}, {""}, {""},
+      {"CSSHIFTJIS", ei_sjis},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"MS-ARAB", ei_cp1256},
+      {""},
+      {"LATIN1", ei_iso8859_1},
+      {""}, {""},
+      {"CP1251", ei_cp1251},
+      {""}, {""},
+      {"GEORGIAN-ACADEMY", ei_georgian_academy},
+      {""}, {""},
+      {"BIG5", ei_ces_big5},
+      {""},
+      {"BIG-5", ei_ces_big5},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-127", ei_iso8859_6},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"MACCROATIAN", ei_mac_croatian},
+      {""}, {""}, {""},
+      {"BIGFIVE", ei_ces_big5},
+      {""},
+      {"BIG-FIVE", ei_ces_big5},
+      {""},
+      {"ISO-IR-203", ei_iso8859_15},
+      {""}, {""},
+      {"MACHEBREW", ei_mac_hebrew},
       {""}, {""}, {""}, {""},
       {"ISO-IR-57", ei_iso646_cn},
       {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"WINDOWS-1257", ei_cp1257},
-      {""},
-      {"GBK", ei_ces_gbk},
-      {"MULELAO-1", ei_mulelao},
-      {"GREEK", ei_iso8859_7},
-      {"WINDOWS-1253", ei_cp1253},
-      {"CYRILLIC", ei_iso8859_5},
-      {""},
-      {"CP932", ei_cp932},
+      {"LATIN6", ei_iso8859_10},
       {""}, {""},
-      {"MS-TURK", ei_cp1254},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-149", ei_ksc5601},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSISO2022KR", ei_iso2022_kr},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""},
-      {"ISO-8859-7", ei_iso8859_7},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"WINDOWS-1254", ei_cp1254},
-      {""},
-      {"JIS_X0201", ei_jisx0201},
-      {"ISO-8859-3", ei_iso8859_3},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"GB_1988-80", ei_iso646_cn},
-      {"LATIN4", ei_iso8859_4},
-      {""}, {""}, {""}, {""},
-      {"CP1251", ei_cp1251},
+      {"CP1256", ei_cp1256},
+      {"TCVN-5712", ei_tcvn},
       {""}, {""}, {""}, {""}, {""},
-      {"GEORGIAN-PS", ei_georgian_ps},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-203", ei_iso8859_15},
-      {""},
-      {"JIS_C6220-1969-RO", ei_iso646_jp},
-      {""}, {""},
-      {"ISO_8859-3:1988", ei_iso8859_3},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-10646-UCS-2", ei_ucs2},
+      {"UCS-2BE", ei_ucs2be},
+      {"ISO-8859-8", ei_iso8859_8},
+      {""}, {""}, {""}, {""}, {""},
+      {"US-ASCII", ei_ascii},
+      {""}, {""}, {""}, {""}, {""},
+      {"CSISO2022CN", ei_iso2022_cn},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""},
-      {"MS-GREEK", ei_cp1253},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-6:1987", ei_iso8859_6},
-      {""}, {""}, {""},
-      {"JIS_X0212-1990", ei_jisx0212},
-      {"CP949", ei_cp949},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACTURKISH", ei_mac_turkish},
-      {""},
-      {"UTF-7", ei_utf7},
-      {""}, {""}, {""}, {""},
-      {"ISO_8859-4:1988", ei_iso8859_4},
-      {"JIS_X0212.1990-0", ei_jisx0212},
+      {"CSVISCII", ei_viscii},
       {""}, {""},
-      {"MS-ARAB", ei_cp1256},
-      {"ISO-8859-4", ei_iso8859_4},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACCENTRALEUROPE", ei_mac_centraleurope},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-2:1987", ei_iso8859_2},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"MS_KANJI", ei_sjis},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"LATIN5", ei_iso8859_9},
+      {""}, {""},
+      {"CP1255", ei_cp1255},
       {""}, {""}, {""},
-      {"UCS-4", ei_ucs4},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"L7", ei_iso8859_13},
       {""},
-      {"GB2312", ei_euc_cn},
-      {""}, {""}, {""}, {""}, {""},
-      {"CSISOLATIN1", ei_iso8859_1},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""},
       {"ISO-IR-157", ei_iso8859_10},
-      {"ISO_8859-14:1998", ei_iso8859_14},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSEUCKR", ei_euc_kr},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""},
-      {"TIS620.2533-0", ei_tis620},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-8859-2", ei_iso8859_2},
+      {"L3", ei_iso8859_3},
       {""}, {""}, {""}, {""}, {""},
-      {"CSMACINTOSH", ei_mac_roman},
+      {"UTF-16", ei_utf16},
+      {""}, {""},
+      {"JOHAB", ei_johab},
+      {"WINDOWS-1254", ei_cp1254},
+      {"MS_KANJI", ei_sjis},
+      {"MACUKRAINE", ei_mac_ukraine},
       {""}, {""}, {""},
       {"VISCII1.1-1", ei_viscii},
-      {""}, {""}, {""}, {""},
-      {"ISO_646.IRV:1991", ei_ascii},
-      {""}, {""}, {""},
-      {"ISO-IR-127", ei_iso8859_6},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-8859-13", ei_iso8859_13},
+      {"CSMACINTOSH", ei_mac_roman},
       {""}, {""},
-      {"JIS_X0208-1983", ei_jisx0208},
-      {""}, {""}, {""}, {""}, {""},
       {"TCVN5712-1", ei_tcvn},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"SHIFT_JIS", ei_sjis},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-14", ei_iso646_jp},
-      {"CSISO58GB231280", ei_gb2312},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"UCS-4-SWAPPED", ei_ucs4swapped},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""},
-      {"ISO_8859-1:1987", ei_iso8859_1},
-      {""},
-      {"CSISO14JISC6220RO", ei_iso646_jp},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSISOLATINCYRILLIC", ei_iso8859_5},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CN-GB-ISOIR165", ei_isoir165},
       {""}, {""}, {""},
-      {"UNICODE-1-1", ei_ucs2be},
+      {"KOI8-U", ei_koi8_u},
+      {""}, {""},
+      {"ISO-8859-1", ei_iso8859_1},
       {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACUKRAINE", ei_mac_ukraine},
+      {"ISO646-JP", ei_iso646_jp},
       {""},
-      {"MACCYRILLIC", ei_mac_cyrillic},
-      {""}, {""}, {""},
-      {"UNICODEBIG", ei_ucs2be},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-7", ei_iso8859_7},
-      {"ISO-8859-14", ei_iso8859_14},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-3", ei_iso8859_3},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSISOLATINGREEK", ei_iso8859_7},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACGREEK", ei_mac_greek},
-      {""}, {""}, {""},
-      {"TIS620.2533-1", ei_tis620},
+      {"WINBALTRIM", ei_cp1257},
       {""},
-      {"HZ-GB-2312", ei_hz},
+      {"KOI8-RU", ei_koi8_ru},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CSISOLATINARABIC", ei_iso8859_6},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"IBM367", ei_ascii},
-      {"CSEUCPKDFMTJAPANESE", ei_euc_jp},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {"CP1361", ei_johab},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"ISO-8859-10", ei_iso8859_10},
       {""},
-      {"ISO_8859-4", ei_iso8859_4},
-      {"MACICELAND", ei_mac_iceland},
+      {"CSISOLATIN2", ei_iso8859_2},
       {""},
+      {"CSIBM866", ei_cp866},
+      {""}, {""}, {""}, {""}, {""},
       {"ARABIC", ei_iso8859_6},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"CP1257", ei_cp1257},
+      {""}, {""}, {""},
+      {"CSISOLATINHEBREW", ei_iso8859_8},
+      {"ISO-8859-6", ei_iso8859_6},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"CSBIG5", ei_ces_big5},
       {""},
-      {"CSISO57GB1988", ei_iso646_cn},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CP1253", ei_cp1253},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACCROATIAN", ei_mac_croatian},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-10646-UCS-4", ei_ucs4},
-      {"KSC_5601", ei_ksc5601},
-      {""}, {""}, {""},
-      {"ISO_8859-7:1987", ei_iso8859_7},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"GB_2312-80", ei_gb2312},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"UNICODE-1-1-UTF-7", ei_utf7},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"CSGB2312", ei_euc_cn},
-      {""}, {""},
-      {"CSHALFWIDTHKATAKANA", ei_jisx0201},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""},
-      {"ISO_8859-13", ei_iso8859_13},
+      {"CN-BIG5", ei_ces_big5},
+      {""},
+      {"UCS-2LE", ei_ucs2le},
+      {""},
+      {"MACTURKISH", ei_mac_turkish},
+      {""},
+      {"HZ-GB-2312", ei_hz},
       {""}, {""}, {""}, {""},
-      {"CP1254", ei_cp1254},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"CSUNICODE11", ei_ucs2be},
-      {""}, {""}, {""}, {""}, {""},
-      {"CSISOLATIN3", ei_iso8859_3},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"CP367", ei_ascii},
-      {"WINDOWS-874", ei_cp874},
+      {"UNICODE-1-1", ei_ucs2be},
       {""}, {""}, {""},
+      {"CSISOLATIN1", ei_iso8859_1},
+      {"CN-GB", ei_euc_cn},
+      {""},
+      {"IBM367", ei_ascii},
+      {""}, {""}, {""},
+      {"UTF-16BE", ei_utf16be},
+      {""}, {""}, {""},
+      {"ISO-8859-5", ei_iso8859_5},
+      {""}, {""}, {""}, {""},
+      {"UCS-2-INTERNAL", ei_ucs2internal},
+      {"UHC", ei_cp949},
+      {""},
+      {"CSISOLATINGREEK", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""},
+      {"CSEUCTW", ei_euc_tw},
+      {""}, {""},
+      {"ISO-8859-16", ei_iso8859_16},
+      {""}, {""}, {""},
+      {"L4", ei_iso8859_4},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"UCS-4-SWAPPED", ei_ucs4swapped},
+      {"ISO646-CN", ei_iso646_cn},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+      {"CSISOLATIN6", ei_iso8859_10},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-8859-15", ei_iso8859_15},
+      {""}, {""},
+      {"CSEUCKR", ei_euc_kr},
+      {"CSUNICODE", ei_ucs2},
+      {""}, {""},
+      {"TIS620.2533-0", ei_tis620},
+      {""}, {""}, {""}, {""},
+      {"LATIN7", ei_iso8859_13},
+      {""}, {""},
+      {"CP1257", ei_cp1257},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"TIS620.2533-1", ei_tis620},
+      {"UTF-7", ei_utf7},
       {"TCVN5712-1:1993", ei_tcvn},
       {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"MACROMANIA", ei_mac_romania},
+      {"CSISOLATIN5", ei_iso8859_9},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"LATIN3", ei_iso8859_3},
+      {"CP950", ei_cp950},
+      {""},
+      {"CP1253", ei_cp1253},
+      {""},
+      {"TIS620.2529-1", ei_tis620},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-14", ei_iso646_jp},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""},
+      {"CSISO87JISX0208", ei_jisx0208},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO646-US", ei_ascii},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CSGB2312", ei_euc_cn},
+      {""}, {""},
+      {"CSISOLATINARABIC", ei_iso8859_6},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"MACCENTRALEUROPE", ei_mac_centraleurope},
+      {"EXTENDED_UNIX_CODE_PACKED_FORMAT_FOR_JAPANESE", ei_euc_jp},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""},
+      {"UNICODE-1-1-UTF-7", ei_utf7},
+      {""}, {""}, {""}, {""}, {""},
+      {"MULELAO-1", ei_mulelao},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CSHALFWIDTHKATAKANA", ei_jisx0201},
+      {""}, {""},
+      {"UTF-16LE", ei_utf16le},
+      {""}, {""},
+      {"ECMA-114", ei_iso8859_6},
+      {""}, {""},
+      {"UCS-4BE", ei_ucs4be},
+      {""},
+      {"CSISO58GB231280", ei_gb2312},
+      {""}, {""}, {""}, {""}, {""},
+      {"ELOT_928", ei_iso8859_7},
+      {"CSEUCPKDFMTJAPANESE", ei_euc_jp},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"MACICELAND", ei_mac_iceland},
+      {""},
+      {"CP932", ei_cp932},
+      {"MACARABIC", ei_mac_arabic},
+      {""}, {""}, {""},
+      {"CP367", ei_ascii},
+      {""}, {""}, {""}, {""}, {""},
+      {"GB_2312-80", ei_gb2312},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CSUNICODE11", ei_ucs2be},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"IBM819", ei_iso8859_1},
+      {""},
+      {"UNICODELITTLE", ei_ucs2le},
+      {""}, {""}, {""}, {""},
+      {"JIS_X0208", ei_jisx0208},
+      {""},
+      {"CSISO159JISX02121990", ei_jisx0212},
+      {""}, {""}, {""},
+      {"ISO-8859-7", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"UNICODEBIG", ei_ucs2be},
+      {""}, {""},
+      {"ISO-10646-UCS-2", ei_ucs2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+      {"CP1133", ei_cp1133},
+      {"CSISO14JISC6220RO", ei_iso646_jp},
+      {"JIS_C6220-1969-RO", ei_iso646_jp},
+      {""}, {""}, {""}, {""}, {""},
+      {"ISO-8859-3", ei_iso8859_3},
+      {"ISO_8859-8", ei_iso8859_8},
+      {"KSC_5601", ei_ksc5601},
+      {"ISO-IR-109", ei_iso8859_3},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"IBM-CP1133", ei_cp1133},
+      {""},
+      {"ISO_8859-8:1988", ei_iso8859_8},
+      {""}, {""}, {""},
+      {"MS-CYRL", ei_cp1251},
+      {""}, {""},
+      {"JIS_X0212", ei_jisx0212},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+      {"WINDOWS-874", ei_cp874},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CP936", ei_ces_gbk},
+      {"ISO_8859-2", ei_iso8859_2},
+      {""}, {""}, {""}, {""}, {""},
+      {"ISO-8859-13", ei_iso8859_13},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"JIS_X0208-1990", ei_jisx0208},
+      {""},
+      {"ISO-IR-159", ei_jisx0212},
+      {""}, {""}, {""}, {""}, {""},
+      {"JIS_X0201", ei_jisx0201},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"CSISOLATINCYRILLIC", ei_iso8859_5},
+      {""}, {""},
+      {"CSISOLATIN3", ei_iso8859_3},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"UCS-4LE", ei_ucs4le},
+      {""}, {""}, {""},
+      {"UCS-4", ei_ucs4},
+      {""}, {""}, {""}, {""}, {""},
+      {"JIS_X0212-1990", ei_jisx0212},
+      {""}, {""}, {""}, {""},
+      {"ISO_8859-1", ei_iso8859_1},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"UCS-4-INTERNAL", ei_ucs4internal},
+      {""},
+      {"ISO_8859-5:1988", ei_iso8859_5},
+      {"ISO_8859-10:1992", ei_iso8859_10},
+      {"CSUNICODE11UTF7", ei_utf7},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"GB_1988-80", ei_iso646_cn},
+      {""},
+      {"ISO_8859-10", ei_iso8859_10},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"JIS_X0212.1990-0", ei_jisx0212},
+      {"JISX0201-1976", ei_jisx0201},
+      {""}, {""}, {""},
+      {"ISO_8859-15:1998", ei_iso8859_15},
+      {""}, {""},
+      {"ISO_8859-6", ei_iso8859_6},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"LATIN4", ei_iso8859_4},
+      {"CP819", ei_iso8859_1},
+      {""},
+      {"CP1254", ei_cp1254},
+      {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-16:2000", ei_iso8859_16},
+      {""}, {""}, {""}, {""},
+      {"ISO-IR-179", ei_iso8859_13},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-5", ei_iso8859_5},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"CP874", ei_cp874},
+      {""}, {""},
+      {"ISO_8859-16", ei_iso8859_16},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"ISO-IR-144", ei_iso8859_5},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-3:1988", ei_iso8859_3},
+      {"ISO_8859-15", ei_iso8859_15},
+      {""}, {""},
+      {"JIS_X0208-1983", ei_jisx0208},
+      {""}, {""}, {""}, {""},
+      {"ISO_646.IRV:1991", ei_ascii},
+      {"ISO_8859-2:1987", ei_iso8859_2},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"ISO_8859-1:1987", ei_iso8859_1},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"ISO_8859-6:1987", ei_iso8859_6},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"ISO-8859-4", ei_iso8859_4},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""},
+      {"CSISO57GB1988", ei_iso646_cn},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-10646-UCS-4", ei_ucs4},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO-IR-149", ei_ksc5601},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""},
+      {"ISO-8859-14", ei_iso8859_14},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"ISO_8859-4:1988", ei_iso8859_4},
+      {""},
+      {"CSISOLATIN4", ei_iso8859_4},
+      {""}, {""}, {""},
+      {"ISO-IR-199", ei_iso8859_14},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-7", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CYRILLIC", ei_iso8859_5},
+      {"CSKSC56011987", ei_ksc5601},
+      {""}, {""},
+      {"ISO_8859-7:1987", ei_iso8859_7},
+      {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-14:1998", ei_iso8859_14},
+      {""},
+      {"ISO-8859-9", ei_iso8859_9},
+      {"ISO_8859-3", ei_iso8859_3},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
+      {"ISO_8859-13", ei_iso8859_13},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ANSI_X3.4-1968", ei_ascii},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CSUCS4", ei_ucs4},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""},
+      {"KS_C_5601-1987", ei_ksc5601},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"CSPC850MULTILINGUAL", ei_cp850},
+      {""}, {""}, {""}, {""},
+      {"MACCYRILLIC", ei_mac_cyrillic},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-4", ei_iso8859_4},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""},
       {"ISO_8859-14", ei_iso8859_14},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-9", ei_iso8859_9},
+      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""},
-      {"CP874", ei_cp874},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"CSISOLATIN4", ei_iso8859_4},
-      {""}, {""}, {""},
-      {"CSUCS4", ei_ucs4},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"GEORGIAN-ACADEMY", ei_georgian_academy},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ISO-IR-144", ei_iso8859_5},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"CSUNICODE11UTF7", ei_utf7},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"MACARABIC", ei_mac_arabic},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"ECMA-114", ei_iso8859_6},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
       {"KS_C_5601-1989", ei_ksc5601},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""},
-      {"ANSI_X3.4-1968", ei_ascii},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""},
-      {"CSKSC56011987", ei_ksc5601},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""},
-      {"CP1133", ei_cp1133},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
+      {"ISO_8859-9:1989", ei_iso8859_9},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
       {""},
-      {"IBM-CP1133", ei_cp1133},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"KS_C_5601-1987", ei_ksc5601}
+      {"CP949", ei_cp949}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/src/converters.h b/src/converters.h
index 1c8f47b..26b1837 100644
--- a/src/converters.h
+++ b/src/converters.h
@@ -97,7 +97,11 @@
 /* General multi-byte encodings */
 #include "utf8.h"
 #include "ucs2.h"
+#include "ucs2be.h"
+#include "ucs2le.h"
 #include "ucs4.h"
+#include "ucs4be.h"
+#include "ucs4le.h"
 #include "utf16.h"
 #include "utf16be.h"
 #include "utf16le.h"
diff --git a/src/encodings.def b/src/encodings.def
index 870a79f..9787a21 100644
--- a/src/encodings.def
+++ b/src/encodings.def
@@ -66,6 +66,20 @@
             ucs2,
             { ucs2_mbtowc },              { ucs2_wctomb, NULL })
 
+DEFENCODING(( "UCS-2BE",                /* glibc */
+              "UNICODEBIG",             /* glibc */
+              "UNICODE-1-1",            /* IANA */
+              "csUnicode11",            /* IANA */
+            ),
+            ucs2be,
+            { ucs2be_mbtowc },            { ucs2be_wctomb, NULL })
+
+DEFENCODING(( "UCS-2LE",                /* glibc */
+              "UNICODELITTLE",          /* glibc */
+            ),
+            ucs2le,
+            { ucs2le_mbtowc },            { ucs2le_wctomb, NULL })
+
 DEFENCODING(( "UCS-4",                  /* glibc */
               "ISO-10646-UCS-4",        /* IANA */
               "csUCS4",                 /* IANA */
@@ -73,6 +87,16 @@
             ucs4,
             { ucs4_mbtowc },              { ucs4_wctomb, NULL })
 
+DEFENCODING(( "UCS-4BE",                /* glibc */
+            ),
+            ucs4be,
+            { ucs4be_mbtowc },            { ucs4be_wctomb, NULL })
+
+DEFENCODING(( "UCS-4LE",                /* glibc */
+            ),
+            ucs4le,
+            { ucs4le_mbtowc },            { ucs4le_wctomb, NULL })
+
 DEFENCODING(( "UTF-16",                 /* RFC 2781 */
             ),
             utf16,
@@ -105,20 +129,6 @@
             ucs2swapped,
             { ucs2swapped_mbtowc },       { ucs2swapped_wctomb, NULL })
 
-DEFENCODING(( "UCS-2-BE",
-              "UNICODEBIG",             /* glibc */
-              "UNICODE-1-1",            /* IANA */
-              "csUnicode11",            /* IANA */
-            ),
-            ucs2be,
-            { ucs2be_mbtowc },            { ucs2be_wctomb, NULL })
-
-DEFENCODING(( "UCS-2-LE",
-              "UNICODELITTLE",          /* glibc */
-            ),
-            ucs2le,
-            { ucs2le_mbtowc },            { ucs2le_wctomb, NULL })
-
 DEFENCODING(( "UCS-4-INTERNAL",         /* libiconv */
             ),
             ucs4internal,
@@ -129,16 +139,6 @@
             ucs4swapped,
             { ucs4swapped_mbtowc },       { ucs4swapped_wctomb, NULL })
 
-DEFENCODING(( "UCS-4-BE",
-            ),
-            ucs4be,
-            { ucs4be_mbtowc },            { ucs4be_wctomb, NULL })
-
-DEFENCODING(( "UCS-4-LE",
-            ),
-            ucs4le,
-            { ucs4le_mbtowc },            { ucs4le_wctomb, NULL })
-
 DEFENCODING(( "JAVA",
             ),
             java,
diff --git a/src/flags.h b/src/flags.h
index 51af911..a122ec2 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -15,19 +15,19 @@
 #define ei_ascii_oflags (0)
 #define ei_utf8_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs2_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
+#define ei_ucs2be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
+#define ei_ucs2le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs4_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
+#define ei_ucs4be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
+#define ei_ucs4le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_utf16_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_utf16be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_utf16le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_utf7_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs2internal_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs2swapped_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
-#define ei_ucs2be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
-#define ei_ucs2le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs4internal_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_ucs4swapped_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
-#define ei_ucs4be_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
-#define ei_ucs4le_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_java_oflags (HAVE_ACCENTS | HAVE_QUOTATION_MARKS | HAVE_HANGUL_JAMO)
 #define ei_iso8859_1_oflags (HAVE_ACCENTS)
 #define ei_iso8859_2_oflags (HAVE_ACCENTS)
diff --git a/src/ucs2be.h b/src/ucs2be.h
new file mode 100644
index 0000000..092ab49
--- /dev/null
+++ b/src/ucs2be.h
@@ -0,0 +1,27 @@
+/*
+ * UCS-2BE = UCS-2 big endian
+ */
+
+static int
+ucs2be_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+  if (n >= 2) {
+    *pwc = (s[0] << 8) + s[1];
+    return 2;
+  }
+  return RET_TOOFEW(0);
+}
+
+static int
+ucs2be_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+{
+  if (wc < 0x10000) {
+    if (n >= 2) {
+      r[0] = (unsigned char) (wc >> 8);
+      r[1] = (unsigned char) wc;
+      return 2;
+    } else
+      return RET_TOOSMALL;
+  }
+  return RET_ILSEQ;
+}
diff --git a/src/ucs2le.h b/src/ucs2le.h
new file mode 100644
index 0000000..ba2e119
--- /dev/null
+++ b/src/ucs2le.h
@@ -0,0 +1,27 @@
+/*
+ * UCS-2LE = UCS-2 little endian
+ */
+
+static int
+ucs2le_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+  if (n >= 2) {
+    *pwc = s[0] + (s[1] << 8);
+    return 2;
+  }
+  return RET_TOOFEW(0);
+}
+
+static int
+ucs2le_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+{
+  if (wc < 0x10000) {
+    if (n >= 2) {
+      r[0] = (unsigned char) wc;
+      r[1] = (unsigned char) (wc >> 8);
+      return 2;
+    } else
+      return RET_TOOSMALL;
+  }
+  return RET_ILSEQ;
+}
diff --git a/src/ucs2swapped.h b/src/ucs2swapped.h
index 5aea47c..b733f8f 100644
--- a/src/ucs2swapped.h
+++ b/src/ucs2swapped.h
@@ -28,20 +28,3 @@
   } else
     return RET_ILSEQ;
 }
-
-/*
- * UCS-2-BE = UCS-2 big endian, with machine dependent alignment
- * UCS-2-LE = UCS-2 little endian, with machine dependent alignment
- */
-
-#ifdef WORDS_LITTLEENDIAN
-#define ucs2be_mbtowc ucs2swapped_mbtowc
-#define ucs2be_wctomb ucs2swapped_wctomb
-#define ucs2le_mbtowc ucs2internal_mbtowc
-#define ucs2le_wctomb ucs2internal_wctomb
-#else
-#define ucs2be_mbtowc ucs2internal_mbtowc
-#define ucs2be_wctomb ucs2internal_wctomb
-#define ucs2le_mbtowc ucs2swapped_mbtowc
-#define ucs2le_wctomb ucs2swapped_wctomb
-#endif
diff --git a/src/ucs4be.h b/src/ucs4be.h
new file mode 100644
index 0000000..6e85be7
--- /dev/null
+++ b/src/ucs4be.h
@@ -0,0 +1,26 @@
+/*
+ * UCS-4BE = UCS-4 big endian
+ */
+
+static int
+ucs4be_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+  if (n >= 4) {
+    *pwc = (s[0] << 24) + (s[1] << 16) + (s[2] << 8) + s[3];
+    return 4;
+  }
+  return RET_TOOFEW(0);
+}
+
+static int
+ucs4be_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+{
+  if (n >= 4) {
+    r[0] = (unsigned char) (wc >> 24);
+    r[1] = (unsigned char) (wc >> 16);
+    r[2] = (unsigned char) (wc >> 8);
+    r[3] = (unsigned char) wc;
+    return 4;
+  } else
+    return RET_TOOSMALL;
+}
diff --git a/src/ucs4le.h b/src/ucs4le.h
new file mode 100644
index 0000000..285a77b
--- /dev/null
+++ b/src/ucs4le.h
@@ -0,0 +1,26 @@
+/*
+ * UCS-4LE = UCS-4 little endian
+ */
+
+static int
+ucs4le_mbtowc (conv_t conv, wchar_t *pwc, const unsigned char *s, int n)
+{
+  if (n >= 4) {
+    *pwc = s[0] + (s[1] << 8) + (s[2] << 16) + (s[3] << 24);
+    return 4;
+  }
+  return RET_TOOFEW(0);
+}
+
+static int
+ucs4le_wctomb (conv_t conv, unsigned char *r, wchar_t wc, int n)
+{
+  if (n >= 4) {
+    r[0] = (unsigned char) wc;
+    r[1] = (unsigned char) (wc >> 8);
+    r[2] = (unsigned char) (wc >> 16);
+    r[3] = (unsigned char) (wc >> 24);
+    return 4;
+  } else
+    return RET_TOOSMALL;
+}
diff --git a/src/ucs4swapped.h b/src/ucs4swapped.h
index 9f408bd..89f2314 100644
--- a/src/ucs4swapped.h
+++ b/src/ucs4swapped.h
@@ -25,20 +25,3 @@
   } else
     return RET_TOOSMALL;
 }
-
-/*
- * UCS-4-BE = UCS-4 big endian, with machine dependent alignment
- * UCS-4-LE = UCS-4 little endian, with machine dependent alignment
- */
-
-#ifdef WORDS_LITTLEENDIAN
-#define ucs4be_mbtowc ucs4swapped_mbtowc
-#define ucs4be_wctomb ucs4swapped_wctomb
-#define ucs4le_mbtowc ucs4internal_mbtowc
-#define ucs4le_wctomb ucs4internal_wctomb
-#else
-#define ucs4be_mbtowc ucs4internal_mbtowc
-#define ucs4be_wctomb ucs4internal_wctomb
-#define ucs4le_mbtowc ucs4swapped_mbtowc
-#define ucs4le_wctomb ucs4swapped_wctomb
-#endif
diff --git a/tests/Makefile.in b/tests/Makefile.in
index b21e99f..a0f0ea8 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -34,10 +34,14 @@
 	./genutf8 > UTF-8.TXT && \
 	$(srcdir)/check-stateless . UTF-8 && \
 	$(RM) genutf8 UTF-8.TXT
-	$(srcdir)/check-stateful $(srcdir) UTF-7
+	$(srcdir)/check-stateful $(srcdir) UCS-2BE
+	$(srcdir)/check-stateful $(srcdir) UCS-2LE
+	$(srcdir)/check-stateful $(srcdir) UCS-4BE
+	$(srcdir)/check-stateful $(srcdir) UCS-4LE
 	$(srcdir)/check-stateful $(srcdir) UTF-16
 	$(srcdir)/check-stateful $(srcdir) UTF-16BE
 	$(srcdir)/check-stateful $(srcdir) UTF-16LE
+	$(srcdir)/check-stateful $(srcdir) UTF-7
 #	/* 8-bit encodings */
 	$(srcdir)/check-stateless $(srcdir) ISO-8859-1
 	$(srcdir)/check-stateless $(srcdir) ISO-8859-2
diff --git a/tests/Makefile.msvc b/tests/Makefile.msvc
new file mode 100644
index 0000000..d5f18b3
--- /dev/null
+++ b/tests/Makefile.msvc
@@ -0,0 +1,168 @@
+# Makefile for libiconv/tests
+
+#### Start of system configuration section. ####
+
+# Flags that can be set on the nmake command line:
+#   STATIC=1  for compiling a static .lib (default is a .dll with a stub .lib)
+!if !defined(STATIC)
+STATIC=0
+!endif
+
+# Directories used by "make":
+srcdir = .
+
+# Programs used by "make":
+CC = cl
+CFLAGS = -MD -W1 -O1
+CPP = cl -E
+INCLUDES = -I. -I$(srcdir) -I..\include -I$(srcdir)\..\include
+RM = del
+
+#### End of system configuration section. ####
+
+SHELL = /bin/sh
+
+all :
+
+check : all table-from.exe table-to.exe iconv.exe uniq-u.exe
+	$(srcdir)\check-stateless.bat $(srcdir) ASCII
+#	/* General multi-byte encodings */
+	$(CC) $(CFLAGS) $(srcdir)\genutf8.c -Fegenutf8.exe
+	$(RM) genutf8.obj
+	.\genutf8 > UTF-8.TXT
+	$(srcdir)\check-stateless.bat . UTF-8
+	$(RM) genutf8.exe
+	$(RM) UTF-8.TXT
+	$(srcdir)\check-stateful.bat $(srcdir) UCS-2BE
+	$(srcdir)\check-stateful.bat $(srcdir) UCS-2LE
+	$(srcdir)\check-stateful.bat $(srcdir) UCS-4BE
+	$(srcdir)\check-stateful.bat $(srcdir) UCS-4LE
+	$(srcdir)\check-stateful.bat $(srcdir) UTF-16
+	$(srcdir)\check-stateful.bat $(srcdir) UTF-16BE
+	$(srcdir)\check-stateful.bat $(srcdir) UTF-16LE
+	$(srcdir)\check-stateful.bat $(srcdir) UTF-7
+#	/* 8-bit encodings */
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-1
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-2
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-3
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-4
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-5
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-6
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-7
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-8
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-9
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-10
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-13
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-14
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-15
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-8859-16
+	$(srcdir)\check-stateless.bat $(srcdir) KOI8-R
+	$(srcdir)\check-stateless.bat $(srcdir) KOI8-U
+	$(srcdir)\check-stateless.bat $(srcdir) KOI8-RU
+	$(srcdir)\check-stateless.bat $(srcdir) CP1250
+	$(srcdir)\check-stateless.bat $(srcdir) CP1251
+	$(srcdir)\check-stateless.bat $(srcdir) CP1252
+	$(srcdir)\check-stateless.bat $(srcdir) CP1253
+	$(srcdir)\check-stateless.bat $(srcdir) CP1254
+	$(srcdir)\check-stateless.bat $(srcdir) CP1255
+	$(srcdir)\check-stateless.bat $(srcdir) CP1256
+	$(srcdir)\check-stateless.bat $(srcdir) CP1257
+	$(srcdir)\check-stateless.bat $(srcdir) CP1258
+	$(srcdir)\check-stateless.bat $(srcdir) CP850
+	$(srcdir)\check-stateless.bat $(srcdir) CP866
+	$(srcdir)\check-stateless.bat $(srcdir) MacRoman
+	$(srcdir)\check-stateless.bat $(srcdir) MacCentralEurope
+	$(srcdir)\check-stateless.bat $(srcdir) MacIceland
+	$(srcdir)\check-stateless.bat $(srcdir) MacCroatian
+	$(srcdir)\check-stateless.bat $(srcdir) MacRomania
+	$(srcdir)\check-stateless.bat $(srcdir) MacCyrillic
+	$(srcdir)\check-stateless.bat $(srcdir) MacUkraine
+	$(srcdir)\check-stateless.bat $(srcdir) MacGreek
+	$(srcdir)\check-stateless.bat $(srcdir) MacTurkish
+	$(srcdir)\check-stateless.bat $(srcdir) MacHebrew
+	$(srcdir)\check-stateless.bat $(srcdir) MacArabic
+	$(srcdir)\check-stateless.bat $(srcdir) MacThai
+	$(srcdir)\check-stateless.bat $(srcdir) HP-ROMAN8
+	$(srcdir)\check-stateless.bat $(srcdir) NEXTSTEP
+	$(srcdir)\check-stateless.bat $(srcdir) ARMSCII-8
+	$(srcdir)\check-stateless.bat $(srcdir) Georgian-Academy
+	$(srcdir)\check-stateless.bat $(srcdir) Georgian-PS
+	$(srcdir)\check-stateless.bat $(srcdir) MuleLao-1
+	$(srcdir)\check-stateless.bat $(srcdir) CP1133
+	$(srcdir)\check-stateless.bat $(srcdir) TIS-620
+	$(srcdir)\check-stateless.bat $(srcdir) CP874
+	$(srcdir)\check-stateless.bat $(srcdir) VISCII
+	$(srcdir)\check-stateless.bat $(srcdir) TCVN
+#	/* CJK character sets */
+	$(srcdir)\check-stateless.bat $(srcdir) ISO646-JP
+	$(srcdir)\check-stateless.bat $(srcdir) JIS_X0201
+#	$(srcdir)\check-stateless.bat $(srcdir) JIS_X0208 # redundant, see EUC-JP
+#	$(srcdir)\check-stateless.bat $(srcdir) JIS_X0212 # redundant, see EUC-JP
+	$(srcdir)\check-stateless.bat $(srcdir) ISO646-CN
+#	$(srcdir)\check-stateless.bat $(srcdir) GB_2312-80 # redundant, see EUC-CN
+	$(srcdir)\check-stateless.bat $(srcdir) ISO-IR-165
+#	$(srcdir)\check-stateless.bat $(srcdir) KSC_5601 # redundant, see EUC-KR
+#	/* CJK encodings */
+	$(srcdir)\check-stateless.bat $(srcdir) EUC-JP
+	$(srcdir)\check-stateless.bat $(srcdir) SHIFT-JIS
+	$(srcdir)\check-stateless.bat $(srcdir) CP932
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-JP
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-JP-2
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-JP-1
+	$(srcdir)\check-stateless.bat $(srcdir) EUC-CN
+	$(srcdir)\check-stateless.bat $(srcdir) GBK
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-CN
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-CN-EXT
+	$(srcdir)\check-stateful.bat $(srcdir) HZ
+	$(srcdir)\check-stateless.bat $(srcdir) EUC-TW
+	$(srcdir)\check-stateless.bat $(srcdir) BIG5
+	$(srcdir)\check-stateless.bat $(srcdir) CP950
+	$(srcdir)\check-stateless.bat $(srcdir) EUC-KR
+	$(srcdir)\check-stateless.bat $(srcdir) CP949
+	$(srcdir)\check-stateless.bat $(srcdir) JOHAB
+	$(srcdir)\check-stateful.bat $(srcdir) ISO-2022-KR
+#	/* transliteration */
+	$(srcdir)\check-translit.bat $(srcdir) Quotes UTF-8 ISO-8859-1
+	$(srcdir)\check-translit.bat $(srcdir) Quotes UTF-8 ASCII
+
+table-from.exe : $(srcdir)/table-from.c ../src/iconv.lib
+	$(CC) $(CFLAGS) $(INCLUDES) $(srcdir)/table-from.c ../src/iconv.lib -Fetable-from.exe
+	$(RM) table-from.obj
+!if !$(STATIC)
+	copy ..\src\iconv.dll iconv.dll
+!endif
+
+table-to.exe : $(srcdir)/table-to.c ../src/iconv.lib
+	$(CC) $(CFLAGS) $(INCLUDES) $(srcdir)/table-to.c ../src/iconv.lib -Fetable-to.exe
+	$(RM) table-to.obj
+!if !$(STATIC)
+	copy ..\src\iconv.dll iconv.dll
+!endif
+
+iconv.exe : $(srcdir)/iconv.c ../src/iconv.lib
+	$(CC) $(CFLAGS) $(INCLUDES) $(srcdir)/iconv.c ../src/iconv.lib -Feiconv.exe
+	$(RM) iconv.obj
+!if !$(STATIC)
+	copy ..\src\iconv.dll iconv.dll
+!endif
+
+uniq-u.exe : $(srcdir)/uniq-u.c
+	$(CC) $(CFLAGS) $(srcdir)/uniq-u.c -Feuniq-u.exe
+	$(RM) uniq-u.obj
+
+mostlyclean : clean
+
+clean : force
+	$(RM) *.obj
+	$(RM) *.dll
+	$(RM) *.exe
+	$(RM) tmp*
+	$(RM) UTF-8.TXT
+	$(RM) core
+
+distclean : clean
+	$(RM) Makefile
+
+maintainer-clean : distclean
+
+force :
diff --git a/tests/UCS-2BE-snippet b/tests/UCS-2BE-snippet
new file mode 100644
index 0000000..dc43740
--- /dev/null
+++ b/tests/UCS-2BE-snippet
Binary files differ
diff --git a/tests/UCS-2BE-snippet.UTF-8 b/tests/UCS-2BE-snippet.UTF-8
new file mode 100644
index 0000000..3705941
--- /dev/null
+++ b/tests/UCS-2BE-snippet.UTF-8
@@ -0,0 +1,46 @@
+This is a list of ways to say hello in various languages.
+Its purpose is to illustrate a number of scripts.
+
+---------------------------------------------------------
+Amharic	(አማርኛ)	ሠላም
+Arabic			ﺍﻟﺴﻼﻡ ﻋﻠﻴﻜﻢ
+Czech (česky)		Dobrý den
+Danish (Dansk)		Hej, Goddag
+English			Hello
+Esperanto		Saluton
+Estonian		Tere, Tervist
+FORTRAN			PROGRAM
+Finnish (Suomi)		Hei
+French (Français)	Bonjour, Salut
+German (Deutsch Nord)	Guten Tag
+German (Deutsch Süd)	Grüß Gott
+Greek (Ελληνικά)	Γειά σας
+Hebrew			שלום
+Italiano		Ciao, Buon giorno
+Lao(ພາສາລາວ)            ສະບາຍດີ, ຂໍໃຫ້ໂຊກດີ
+Maltese			Ciao
+Nederlands, Vlaams	Hallo, Dag
+Norwegian (Norsk)	Hei, God dag
+Polish			Dzień dobry, Hej
+Russian (Русский)	Здравствуйте!
+Slovak			Dobrý deň
+Spanish (Español)	¡Hola!
+Swedish (Svenska)	Hej, Goddag
+Thai (ภาษาไทย)		สวัสดีครับ, สวัสดีค่ะ
+
+Tigrigna (ትግርኛ)	ሰላማት
+Turkish (Türkçe)	Merhaba
+Vietnamese (Tiếng Việt)	Chào bạn
+
+Japanese (日本語)		こんにちは, コンニチハ
+Chinese (中文,普通话,汉语)	你好
+Cantonese (粵語,廣東話)		早晨, 你好
+Korean (한글)			안녕하세요, 안녕하십니까
+
+Difference among chinese characters in GB, JIS, KSC, BIG5:
+	GB   -- 元气  开发
+	JIS  -- 元気  開発
+	KSC  -- 元氣  開發
+	BIG5 -- 元氣  開發
+
+Just for a test of JISX0212: 騏驎 (the second character is of JISX0212)
diff --git a/tests/UCS-2LE-snippet b/tests/UCS-2LE-snippet
new file mode 100644
index 0000000..8fa5ff5
--- /dev/null
+++ b/tests/UCS-2LE-snippet
Binary files differ
diff --git a/tests/UCS-2LE-snippet.UTF-8 b/tests/UCS-2LE-snippet.UTF-8
new file mode 100644
index 0000000..3705941
--- /dev/null
+++ b/tests/UCS-2LE-snippet.UTF-8
@@ -0,0 +1,46 @@
+This is a list of ways to say hello in various languages.
+Its purpose is to illustrate a number of scripts.
+
+---------------------------------------------------------
+Amharic	(አማርኛ)	ሠላም
+Arabic			ﺍﻟﺴﻼﻡ ﻋﻠﻴﻜﻢ
+Czech (česky)		Dobrý den
+Danish (Dansk)		Hej, Goddag
+English			Hello
+Esperanto		Saluton
+Estonian		Tere, Tervist
+FORTRAN			PROGRAM
+Finnish (Suomi)		Hei
+French (Français)	Bonjour, Salut
+German (Deutsch Nord)	Guten Tag
+German (Deutsch Süd)	Grüß Gott
+Greek (Ελληνικά)	Γειά σας
+Hebrew			שלום
+Italiano		Ciao, Buon giorno
+Lao(ພາສາລາວ)            ສະບາຍດີ, ຂໍໃຫ້ໂຊກດີ
+Maltese			Ciao
+Nederlands, Vlaams	Hallo, Dag
+Norwegian (Norsk)	Hei, God dag
+Polish			Dzień dobry, Hej
+Russian (Русский)	Здравствуйте!
+Slovak			Dobrý deň
+Spanish (Español)	¡Hola!
+Swedish (Svenska)	Hej, Goddag
+Thai (ภาษาไทย)		สวัสดีครับ, สวัสดีค่ะ
+
+Tigrigna (ትግርኛ)	ሰላማት
+Turkish (Türkçe)	Merhaba
+Vietnamese (Tiếng Việt)	Chào bạn
+
+Japanese (日本語)		こんにちは, コンニチハ
+Chinese (中文,普通话,汉语)	你好
+Cantonese (粵語,廣東話)		早晨, 你好
+Korean (한글)			안녕하세요, 안녕하십니까
+
+Difference among chinese characters in GB, JIS, KSC, BIG5:
+	GB   -- 元气  开发
+	JIS  -- 元気  開発
+	KSC  -- 元氣  開發
+	BIG5 -- 元氣  開發
+
+Just for a test of JISX0212: 騏驎 (the second character is of JISX0212)
diff --git a/tests/UCS-4BE-snippet b/tests/UCS-4BE-snippet
new file mode 100644
index 0000000..9d76045
--- /dev/null
+++ b/tests/UCS-4BE-snippet
Binary files differ
diff --git a/tests/UCS-4BE-snippet.UTF-8 b/tests/UCS-4BE-snippet.UTF-8
new file mode 100644
index 0000000..d28ea2e
--- /dev/null
+++ b/tests/UCS-4BE-snippet.UTF-8
@@ -0,0 +1 @@
+𒍅=Ra
\ No newline at end of file
diff --git a/tests/UCS-4LE-snippet b/tests/UCS-4LE-snippet
new file mode 100644
index 0000000..00face9
--- /dev/null
+++ b/tests/UCS-4LE-snippet
Binary files differ
diff --git a/tests/UCS-4LE-snippet.UTF-8 b/tests/UCS-4LE-snippet.UTF-8
new file mode 100644
index 0000000..d28ea2e
--- /dev/null
+++ b/tests/UCS-4LE-snippet.UTF-8
@@ -0,0 +1 @@
+𒍅=Ra
\ No newline at end of file
diff --git a/tests/check-stateful.bat b/tests/check-stateful.bat
new file mode 100644
index 0000000..3bdd6be
--- /dev/null
+++ b/tests/check-stateful.bat
@@ -0,0 +1,9 @@
+@ECHO OFF
+REM Simple check of a stateful encoding.
+REM Usage: check-stateful.bat SRCDIR CHARSET
+
+.\iconv -f %2 -t UTF-8 < %1\%2-snippet > tmp-snippet
+fc %1\%2-snippet.UTF-8 tmp-snippet
+.\iconv -f UTF-8 -t %2 < %1\%2-snippet.UTF-8 > tmp-snippet
+fc %1\%2-snippet tmp-snippet
+del tmp-snippet
diff --git a/tests/check-stateless.bat b/tests/check-stateless.bat
new file mode 100644
index 0000000..c92f621
--- /dev/null
+++ b/tests/check-stateless.bat
@@ -0,0 +1,21 @@
+@ECHO OFF
+REM Complete check of a stateless encoding.
+REM Usage: check-stateless.bat SRCDIR CHARSET
+
+.\table-from %2 > tmp-%2.TXT
+.\table-to %2 | sort > tmp-%2.INVERSE.TXT
+fc %1\%2.TXT tmp-%2.TXT
+
+if not exist %1\%2.IRREVERSIBLE.TXT goto ELSE_1
+  copy /a %1\%2.TXT /a + %1\%2.IRREVERSIBLE.TXT /a tmp
+  sort tmp | uniq-u > tmp-orig-%2.INVERSE.TXT
+  fc tmp-orig-%2.INVERSE.TXT tmp-%2.INVERSE.TXT
+  del tmp
+  del tmp-orig-%2.INVERSE.TXT
+  goto ENDIF_1
+:ELSE_1
+  fc %1\%2.TXT tmp-%2.INVERSE.TXT
+:ENDIF_1
+
+del tmp-%2.TXT
+del tmp-%2.INVERSE.TXT
diff --git a/tests/check-translit.bat b/tests/check-translit.bat
new file mode 100644
index 0000000..173cd11
--- /dev/null
+++ b/tests/check-translit.bat
@@ -0,0 +1,7 @@
+@ECHO OFF
+REM Simple check of transliteration facilities.
+REM Usage: check-translit.bat SRCDIR FILE fromcode tocode
+
+.\iconv -f %3 -t %4 < %1\%2.%3 > tmp
+fc %1\%2.%4 tmp
+del tmp
diff --git a/tests/uniq-u.c b/tests/uniq-u.c
new file mode 100644
index 0000000..31b850f
--- /dev/null
+++ b/tests/uniq-u.c
@@ -0,0 +1,278 @@
+/* uniq -- remove duplicate lines from a sorted file
+   Copyright (C) 86, 91, 1995-1998, 1999 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Written by Richard Stallman and David MacKenzie. */
+/* 2000-03-22  Trimmed down to the case of "uniq -u" by Bruno Haible. */
+
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* The name this program was run with. */
+static char *program_name;
+
+static void
+xalloc_fail (void)
+{
+  fprintf (stderr, "%s: virtual memory exhausted\n", program_name);
+  exit (1);
+}
+
+/* Allocate N bytes of memory dynamically, with error checking.  */
+
+void *
+xmalloc (size_t n)
+{
+  void *p;
+
+  p = malloc (n);
+  if (p == 0)
+    xalloc_fail ();
+  return p;
+}
+
+/* Change the size of an allocated block of memory P to N bytes,
+   with error checking.
+   If P is NULL, run xmalloc.  */
+
+void *
+xrealloc (void *p, size_t n)
+{
+  p = realloc (p, n);
+  if (p == 0)
+    xalloc_fail ();
+  return p;
+}
+
+/* A `struct linebuffer' holds a line of text. */
+
+struct linebuffer
+{
+  size_t size;			/* Allocated. */
+  size_t length;		/* Used. */
+  char *buffer;
+};
+
+/* Initialize linebuffer LINEBUFFER for use. */
+
+static void
+initbuffer (struct linebuffer *linebuffer)
+{
+  linebuffer->length = 0;
+  linebuffer->size = 200;
+  linebuffer->buffer = (char *) xmalloc (linebuffer->size);
+}
+
+/* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
+   Keep the newline; append a newline if it's the last line of a file
+   that ends in a non-newline character.  Do not null terminate.
+   Return LINEBUFFER, except at end of file return 0.  */
+
+static struct linebuffer *
+readline (struct linebuffer *linebuffer, FILE *stream)
+{
+  int c;
+  char *buffer = linebuffer->buffer;
+  char *p = linebuffer->buffer;
+  char *end = buffer + linebuffer->size - 1; /* Sentinel. */
+
+  if (feof (stream) || ferror (stream))
+    return 0;
+
+  do
+    {
+      c = getc (stream);
+      if (c == EOF)
+	{
+	  if (p == buffer)
+	    return 0;
+	  if (p[-1] == '\n')
+	    break;
+	  c = '\n';
+	}
+      if (p == end)
+	{
+	  linebuffer->size *= 2;
+	  buffer = (char *) xrealloc (buffer, linebuffer->size);
+	  p = p - linebuffer->buffer + buffer;
+	  linebuffer->buffer = buffer;
+	  end = buffer + linebuffer->size - 1;
+	}
+      *p++ = c;
+    }
+  while (c != '\n');
+
+  linebuffer->length = p - buffer;
+  return linebuffer;
+}
+
+/* Free linebuffer LINEBUFFER's data. */
+
+static void
+freebuffer (struct linebuffer *linebuffer)
+{
+  free (linebuffer->buffer);
+}
+
+/* Undefine, to avoid warning about redefinition on some systems.  */
+#undef min
+#define min(x, y) ((x) < (y) ? (x) : (y))
+
+/* Return zero if two strings OLD and NEW match, nonzero if not.
+   OLD and NEW point not to the beginnings of the lines
+   but rather to the beginnings of the fields to compare.
+   OLDLEN and NEWLEN are their lengths. */
+
+static int
+different (const char *old, const char *new, size_t oldlen, size_t newlen)
+{
+  int order;
+
+  order = memcmp (old, new, min (oldlen, newlen));
+
+  if (order == 0)
+    return oldlen - newlen;
+  return order;
+}
+
+/* Output the line in linebuffer LINE to stream STREAM
+   provided that the switches say it should be output.
+   If requested, print the number of times it occurred, as well;
+   LINECOUNT + 1 is the number of times that the line occurred. */
+
+static void
+writeline (const struct linebuffer *line, FILE *stream, int linecount)
+{
+  if (linecount == 0)
+    fwrite (line->buffer, 1, line->length, stream);
+}
+
+/* Process input file INFILE with output to OUTFILE.
+   If either is "-", use the standard I/O stream for it instead. */
+
+static void
+check_file (const char *infile, const char *outfile)
+{
+  FILE *istream;
+  FILE *ostream;
+  struct linebuffer lb1, lb2;
+  struct linebuffer *thisline, *prevline, *exch;
+  char *prevfield, *thisfield;
+  size_t prevlen, thislen;
+  int match_count = 0;
+
+  if (!strcmp (infile, "-"))
+    istream = stdin;
+  else
+    istream = fopen (infile, "r");
+  if (istream == NULL)
+    {
+      fprintf (stderr, "%s: error opening %s\n", program_name, infile);
+      exit (1);
+    }
+
+  if (!strcmp (outfile, "-"))
+    ostream = stdout;
+  else
+    ostream = fopen (outfile, "w");
+  if (ostream == NULL)
+    {
+      fprintf (stderr, "%s: error opening %s\n", program_name, outfile);
+      exit (1);
+    }
+
+  thisline = &lb1;
+  prevline = &lb2;
+
+  initbuffer (thisline);
+  initbuffer (prevline);
+
+  if (readline (prevline, istream) == 0)
+    goto closefiles;
+  prevfield = prevline->buffer;
+  prevlen = prevline->length;
+
+  while (!feof (istream))
+    {
+      int match;
+      if (readline (thisline, istream) == 0)
+	break;
+      thisfield = thisline->buffer;
+      thislen = thisline->length;
+      match = !different (thisfield, prevfield, thislen, prevlen);
+
+      if (match)
+	++match_count;
+
+      if (!match)
+	{
+	  writeline (prevline, ostream, match_count);
+	  exch = prevline;
+	  prevline = thisline;
+	  thisline = exch;
+	  prevfield = thisfield;
+	  prevlen = thislen;
+	  if (!match)
+	    match_count = 0;
+	}
+    }
+
+  writeline (prevline, ostream, match_count);
+
+ closefiles:
+  if (ferror (istream) || fclose (istream) == EOF)
+    {
+      fprintf (stderr, "%s: error reading %s\n", program_name, infile);
+      exit (1);
+    }
+
+  if (ferror (ostream) || fclose (ostream) == EOF)
+    {
+      fprintf (stderr, "%s: error writing %s\n", program_name, outfile);
+      exit (1);
+    }
+
+  freebuffer (&lb1);
+  freebuffer (&lb2);
+}
+
+int
+main (int argc, char **argv)
+{
+  const char *infile = "-";
+  const char *outfile = "-";
+  int optind = 1;
+
+  program_name = argv[0];
+
+  if (optind < argc)
+    infile = argv[optind++];
+
+  if (optind < argc)
+    outfile = argv[optind++];
+
+  if (optind < argc)
+    {
+      fprintf (stderr, "%s: too many arguments\n", program_name);
+      exit (1);
+    }
+
+  check_file (infile, outfile);
+
+  exit (0);
+}
diff --git a/windows/dllexport.h b/windows/dllexport.h
new file mode 100644
index 0000000..b0fb636
--- /dev/null
+++ b/windows/dllexport.h
@@ -0,0 +1,6 @@
+
+#ifdef BUILDING_LIBICONV
+#define LIBICONV_DLL_EXPORTED __declspec(dllexport)
+#else
+#define LIBICONV_DLL_EXPORTED __declspec(dllimport)
+#endif
diff --git a/windows/iconv.rc b/windows/iconv.rc
new file mode 100644
index 0000000..7930138
--- /dev/null
+++ b/windows/iconv.rc
@@ -0,0 +1,37 @@
+/* Resources for iconv.dll */
+/* There are 4 occurrences of the version number in this file. */
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 1,3,0,0
+ PRODUCTVERSION 1,3,0,0
+ FILEFLAGSMASK 0x3fL /* VS_FFI_FILEFLAGSMASK */
+#ifdef _DEBUG
+ FILEFLAGS 0x1L  /* VS_FF_DEBUG */
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x10004L  /* VOS_DOS_WINDOWS32 */
+ FILETYPE 0x2L  /* VFT_DLL */
+ FILESUBTYPE 0x0L  /* VFT2_UNKNOWN */
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "04090000"  /* Lang = US English, Charset = ASCII */
+        BEGIN
+            VALUE "Comments", "This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\0"
+            VALUE "CompanyName", "Free Software Foundation\0"
+            VALUE "FileDescription", "LGPLed libiconv for Windows NT and Windows 95/98\0"
+            VALUE "FileVersion", "1.3\0"
+            VALUE "InternalName", "iconv.dll\0"
+            VALUE "LegalCopyright", "Copyright (C) 1999-2000\0"
+            VALUE "LegalTrademarks", "\0"
+            VALUE "OriginalFilename", "iconv.dll\0"
+            VALUE "ProductName", "libiconv: character set conversion library\0"
+            VALUE "ProductVersion", "1.3\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x0409, 0  /* US English, ASCII */
+    END
+END