[sword-svn] r122 - in trunk/source: extra extra/scrptrun extra/uconv extra/uconv/resources extra/uconv/samples extra/uconv/samples/utf8 extra/uconv/unicode io io/unicode

chrislit at www.crosswire.org chrislit at www.crosswire.org
Thu Dec 21 03:47:20 MST 2006


Author: chrislit
Date: 2006-12-21 03:47:20 -0700 (Thu, 21 Dec 2006)
New Revision: 122

Modified:
   trunk/source/extra/Makefile.in
   trunk/source/extra/scrptrun/Makefile.in
   trunk/source/extra/scrptrun/readme.html
   trunk/source/extra/scrptrun/scrptrun.cpp
   trunk/source/extra/scrptrun/scrptrun.h
   trunk/source/extra/scrptrun/srtest.cpp
   trunk/source/extra/uconv/Makefile.in
   trunk/source/extra/uconv/README
   trunk/source/extra/uconv/makedata.mak
   trunk/source/extra/uconv/pkgdata.inc.in
   trunk/source/extra/uconv/resfiles.mk
   trunk/source/extra/uconv/resources/fr.txt
   trunk/source/extra/uconv/resources/root.txt
   trunk/source/extra/uconv/samples/ISO-8859-2.txt
   trunk/source/extra/uconv/samples/ISO-8859-3.txt
   trunk/source/extra/uconv/samples/danish-ISO-8859-1.txt
   trunk/source/extra/uconv/samples/eucJP.txt
   trunk/source/extra/uconv/samples/hangul-eucKR.txt
   trunk/source/extra/uconv/samples/hania-eucKR.txt
   trunk/source/extra/uconv/samples/iso8859-1.txt
   trunk/source/extra/uconv/samples/koi8r.txt
   trunk/source/extra/uconv/samples/utf8/armenian.txt
   trunk/source/extra/uconv/samples/utf8/banviet.txt
   trunk/source/extra/uconv/samples/utf8/croat.txt
   trunk/source/extra/uconv/samples/utf8/danish.txt
   trunk/source/extra/uconv/samples/utf8/greek.txt
   trunk/source/extra/uconv/samples/utf8/hangul.txt
   trunk/source/extra/uconv/samples/utf8/hania.txt
   trunk/source/extra/uconv/samples/utf8/many.txt
   trunk/source/extra/uconv/samples/utf8/maopoem.txt
   trunk/source/extra/uconv/samples/utf8/turkish.txt
   trunk/source/extra/uconv/samples/utf8/utf-8-demo.txt
   trunk/source/extra/uconv/uconv.1.in
   trunk/source/extra/uconv/uconv.cpp
   trunk/source/extra/uconv/unicode/uwmsg.h
   trunk/source/extra/uconv/uwmsg.c
   trunk/source/io/Makefile.in
   trunk/source/io/locbund.c
   trunk/source/io/locbund.h
   trunk/source/io/sprintf.c
   trunk/source/io/sscanf.c
   trunk/source/io/ucln_io.c
   trunk/source/io/ucln_io.h
   trunk/source/io/ufile.c
   trunk/source/io/ufile.h
   trunk/source/io/ufmt_cmn.c
   trunk/source/io/ufmt_cmn.h
   trunk/source/io/unicode/ustdio.h
   trunk/source/io/unicode/ustream.h
   trunk/source/io/uprintf.c
   trunk/source/io/uprintf.h
   trunk/source/io/uprntf_p.c
   trunk/source/io/uscanf.c
   trunk/source/io/uscanf.h
   trunk/source/io/uscanf_p.c
   trunk/source/io/ustdio.c
   trunk/source/io/ustream.cpp
Log:
corrected eol properties for *nix builds

Modified: trunk/source/extra/Makefile.in
===================================================================
--- trunk/source/extra/Makefile.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/Makefile.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,77 +1,77 @@
-#******************************************************************************
-#
-#   Copyright (C) 1999-2004, International Business Machines
-#   Corporation and others.  All Rights Reserved.
-#
-#******************************************************************************
-## Makefile.in for ICU extras
-## Stephen F. Booth
-
-## Install directory information
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ..
-
-include $(top_builddir)/icudefs.mk
-
-## Build directory information
-subdir = extra
-
-## Files to remove for 'make clean'
-CLEANFILES = *~
-
-SUBDIRS = uconv
-
-## List of phony targets
-.PHONY : all all-local all-recursive install install-local		\
-install-recursive clean clean-local clean-recursive distclean		\
-distclean-local distclean-recursive dist dist-recursive dist-local	\
-check check-recursive check-local
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-recursive all-local
-install: install-recursive install-local
-clean: clean-recursive clean-local
-distclean : distclean-recursive distclean-local
-dist: dist-recursive dist-local
-check: all check-recursive check-local
-
-## Recursive targets
-all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive:
-	@dot_seen=no; \
-	target=`echo $@ | sed s/-recursive//`; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  echo "$(MAKE)[$(MAKELEVEL)]: Making \`$$target' in \`$$subdir'"; \
-	  if test "$$subdir" = "."; then \
-	    dot_seen=yes; \
-	    local_target="$$target-local"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  (cd $$subdir && $(MAKE) $$local_target) || exit; \
-	done; \
-	if test "$$dot_seen" = "no"; then \
-	  $(MAKE) "$$target-local" || exit; \
-	fi
-
-all-local:
-
-install-local:
-
-dist-local:
-
-clean-local:
-	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
-
-check-local:
-
-distclean-local: clean-local
-	$(RMV) Makefile
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+#******************************************************************************
+#
+#   Copyright (C) 1999-2004, International Business Machines
+#   Corporation and others.  All Rights Reserved.
+#
+#******************************************************************************
+## Makefile.in for ICU extras
+## Stephen F. Booth
+
+## Install directory information
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+
+top_builddir = ..
+
+include $(top_builddir)/icudefs.mk
+
+## Build directory information
+subdir = extra
+
+## Files to remove for 'make clean'
+CLEANFILES = *~
+
+SUBDIRS = uconv
+
+## List of phony targets
+.PHONY : all all-local all-recursive install install-local		\
+install-recursive clean clean-local clean-recursive distclean		\
+distclean-local distclean-recursive dist dist-recursive dist-local	\
+check check-recursive check-local
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-recursive all-local
+install: install-recursive install-local
+clean: clean-recursive clean-local
+distclean : distclean-recursive distclean-local
+dist: dist-recursive dist-local
+check: all check-recursive check-local
+
+## Recursive targets
+all-recursive install-recursive clean-recursive distclean-recursive dist-recursive check-recursive:
+	@dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  echo "$(MAKE)[$(MAKELEVEL)]: Making \`$$target' in \`$$subdir'"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-local"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  (cd $$subdir && $(MAKE) $$local_target) || exit; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) "$$target-local" || exit; \
+	fi
+
+all-local:
+
+install-local:
+
+dist-local:
+
+clean-local:
+	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
+
+check-local:
+
+distclean-local: clean-local
+	$(RMV) Makefile
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status


Property changes on: trunk/source/extra/Makefile.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/scrptrun/Makefile.in
===================================================================
--- trunk/source/extra/scrptrun/Makefile.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/scrptrun/Makefile.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,86 +1,86 @@
-## Makefile.in for ICU - extra/scrptrun
-## Copyright (c) 2001, International Business Machines Corporation and
-## others. All Rights Reserved.
-
-## Source directory information
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ../..
-
-include $(top_builddir)/icudefs.mk
-
-## Platform-specific setup
-include @platform_make_fragment@
-
-## Build directory information
-subdir = extra/scrptrun
-
-## Extra files to remove for 'make clean'
-CLEANFILES = *~ $(DEPS)
-
-## Target information
-TARGET = srtest
-
-DEFS = @DEFS@
-CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir) 
-CFLAGS = @CFLAGS@
-CXXFLAGS = @CXXFLAGS@
-ENABLE_RPATH = @ENABLE_RPATH@
-ifeq ($(ENABLE_RPATH),YES)
-RPATHLDFLAGS = $(LD_RPATH)$(LD_RPATH_PRE)$(libdir)
-endif
-LDFLAGS = @LDFLAGS@ $(RPATHLDFLAGS)
-LIBS = $(LIBICUUC) @LIBS@ @LIB_M@
-
-OBJECTS = scrptrun.o srtest.o
-
-DEPS = $(OBJECTS:.o=.d)
-
-## List of phony targets
-.PHONY : all all-local install install-local clean clean-local	\
-distclean distclean-local dist dist-local check check-local
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-local
-install: install-local
-clean: clean-local
-distclean : distclean-local
-dist: dist-local
-check: all check-local
-
-all-local: $(TARGET)
-
-install-local:
-
-dist-local:
-
-clean-local:
-	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
-	$(RMV) $(OBJECTS) $(TARGET)
-
-distclean-local: clean-local
-	$(RMV) Makefile
-
-check-local: all-local
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(TARGET) : $(OBJECTS)
-	$(LINK.cc) -o $@ $^ $(LIBS)
-
-invoke:
-	ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
-
-ifeq (,$(MAKECMDGOALS))
--include $(DEPS)
-else
-ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
--include $(DEPS)
-endif
-endif
+## Makefile.in for ICU - extra/scrptrun
+## Copyright (c) 2001, International Business Machines Corporation and
+## others. All Rights Reserved.
+
+## Source directory information
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+
+top_builddir = ../..
+
+include $(top_builddir)/icudefs.mk
+
+## Platform-specific setup
+include @platform_make_fragment@
+
+## Build directory information
+subdir = extra/scrptrun
+
+## Extra files to remove for 'make clean'
+CLEANFILES = *~ $(DEPS)
+
+## Target information
+TARGET = srtest
+
+DEFS = @DEFS@
+CPPFLAGS = @CPPFLAGS@ -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir) 
+CFLAGS = @CFLAGS@
+CXXFLAGS = @CXXFLAGS@
+ENABLE_RPATH = @ENABLE_RPATH@
+ifeq ($(ENABLE_RPATH),YES)
+RPATHLDFLAGS = $(LD_RPATH)$(LD_RPATH_PRE)$(libdir)
+endif
+LDFLAGS = @LDFLAGS@ $(RPATHLDFLAGS)
+LIBS = $(LIBICUUC) @LIBS@ @LIB_M@
+
+OBJECTS = scrptrun.o srtest.o
+
+DEPS = $(OBJECTS:.o=.d)
+
+## List of phony targets
+.PHONY : all all-local install install-local clean clean-local	\
+distclean distclean-local dist dist-local check check-local
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-local
+install: install-local
+clean: clean-local
+distclean : distclean-local
+dist: dist-local
+check: all check-local
+
+all-local: $(TARGET)
+
+install-local:
+
+dist-local:
+
+clean-local:
+	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
+	$(RMV) $(OBJECTS) $(TARGET)
+
+distclean-local: clean-local
+	$(RMV) Makefile
+
+check-local: all-local
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(TARGET) : $(OBJECTS)
+	$(LINK.cc) -o $@ $^ $(LIBS)
+
+invoke:
+	ICU_DATA=$${ICU_DATA:-$(top_builddir)/data/} TZ=PST8PDT $(INVOKE) $(INVOCATION)
+
+ifeq (,$(MAKECMDGOALS))
+-include $(DEPS)
+else
+ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
+-include $(DEPS)
+endif
+endif


Property changes on: trunk/source/extra/scrptrun/Makefile.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/scrptrun/readme.html
===================================================================
--- trunk/source/extra/scrptrun/readme.html	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/scrptrun/readme.html	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,68 +1,68 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
-   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-   <meta name="Copyright" content="Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.">
-   <meta name="Author" content="Eric Mader">
-   <meta name="GENERATOR" content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
-   <title>ScriptRun readme</title>
-</head>
-<body>
-
-<h2>
-What is scrptrun and srtest?</h2>
-The ICU LayoutEngine must be called with text in a single script. scrptrun.h
-and scrptrun.cpp implement the ScriptRun class, which can be used to find
-runs of text that is in a single script. It uses a basic iteration interface.
-<p>srtest is a little program that tests ScriptRun. You can use it as an
-example of how to use ScriptRun. Here's what the output should look like:
-<blockquote><font face="Courier New,Courier"><font size=-1>Script 'DEVANAGARI'
-from 0 to 9.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'ARABIC' from
-9 to 17.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'CYRILLIC' from
-17 to 25.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'LATIN' from
-25 to 33.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'HAN' from 33
-to 35.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'HIRAGANA' from
-35 to 41.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'KATAKANA' from
-41 to 45.</font></font>
-<br><font face="Courier New,Courier"><font size=-1>Script 'DESERET' from
-45 to 53.</font></font></blockquote>
-
-<h2>
-How do I build scrptrun and srtest?</h2>
-To use the ScriptRun class in a Windows application, just include scrptrun.h
-and scrptrun.cpp right out of the &lt;icu>\source\extra\scrptrun directory
-into your project. You'll also need to add the &lt;icu>\source]extra\scrptrun
-directory to the "Additional include directories" section of the "Preprocessor"
-category on the "C/C++" tab in the project settings.
-<p>On UNIX systems the simplest thing to do is to just copy scrptrun.h
-and scrptrun.cpp into your source directory. If you want to use them from
-&lt;icu>/source/extra/scrpturn, it's a bit trickier: the default dependency
-rules don't work on source files in a different directory. You need to
-add separate dependency rules for scrptrun.o and scrptrun.d. See &lt;icu>/source/samples/layout/Makefile.in
-for an example of how to do this. You'll also have to add -I$(top_srcdir)/extra/scrptrun
-to your compiler flags so that the compiler can find scrptrun.h. If your
-application has to build on multiple UNIX platforms, it might be difficult
-to wirte dependency rules that will work correctly on all platforms. In
-that case, you're probably better off copying the scrpturn files to your
-source directory.
-<p>Building srtest is easy, on Windows build the srtest workspace in &lt;icu>\source\extra\scrptrun.
-On UNIX, connect to &lt;top-build-dir>/extra/scrptrun and do "make all"
-<h2>
-Notes</h2>
-
-<ul>
-<li>
-ScriptRun is based on <a href="http://www.unicode.org/unicode/reports/tr24/">Unicode
-Technical Report #24</a> but the implementation is not complete. In particular
-the support for paired punctuation is only a prototype. A complete implementation
-will be added to ICU in the future.</li>
-</ul>
-
-</body>
-</html>
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+   <meta name="Copyright" content="Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.">
+   <meta name="Author" content="Eric Mader">
+   <meta name="GENERATOR" content="Mozilla/4.72 [en] (Windows NT 5.0; U) [Netscape]">
+   <title>ScriptRun readme</title>
+</head>
+<body>
+
+<h2>
+What is scrptrun and srtest?</h2>
+The ICU LayoutEngine must be called with text in a single script. scrptrun.h
+and scrptrun.cpp implement the ScriptRun class, which can be used to find
+runs of text that is in a single script. It uses a basic iteration interface.
+<p>srtest is a little program that tests ScriptRun. You can use it as an
+example of how to use ScriptRun. Here's what the output should look like:
+<blockquote><font face="Courier New,Courier"><font size=-1>Script 'DEVANAGARI'
+from 0 to 9.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'ARABIC' from
+9 to 17.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'CYRILLIC' from
+17 to 25.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'LATIN' from
+25 to 33.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'HAN' from 33
+to 35.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'HIRAGANA' from
+35 to 41.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'KATAKANA' from
+41 to 45.</font></font>
+<br><font face="Courier New,Courier"><font size=-1>Script 'DESERET' from
+45 to 53.</font></font></blockquote>
+
+<h2>
+How do I build scrptrun and srtest?</h2>
+To use the ScriptRun class in a Windows application, just include scrptrun.h
+and scrptrun.cpp right out of the &lt;icu>\source\extra\scrptrun directory
+into your project. You'll also need to add the &lt;icu>\source]extra\scrptrun
+directory to the "Additional include directories" section of the "Preprocessor"
+category on the "C/C++" tab in the project settings.
+<p>On UNIX systems the simplest thing to do is to just copy scrptrun.h
+and scrptrun.cpp into your source directory. If you want to use them from
+&lt;icu>/source/extra/scrpturn, it's a bit trickier: the default dependency
+rules don't work on source files in a different directory. You need to
+add separate dependency rules for scrptrun.o and scrptrun.d. See &lt;icu>/source/samples/layout/Makefile.in
+for an example of how to do this. You'll also have to add -I$(top_srcdir)/extra/scrptrun
+to your compiler flags so that the compiler can find scrptrun.h. If your
+application has to build on multiple UNIX platforms, it might be difficult
+to wirte dependency rules that will work correctly on all platforms. In
+that case, you're probably better off copying the scrpturn files to your
+source directory.
+<p>Building srtest is easy, on Windows build the srtest workspace in &lt;icu>\source\extra\scrptrun.
+On UNIX, connect to &lt;top-build-dir>/extra/scrptrun and do "make all"
+<h2>
+Notes</h2>
+
+<ul>
+<li>
+ScriptRun is based on <a href="http://www.unicode.org/unicode/reports/tr24/">Unicode
+Technical Report #24</a> but the implementation is not complete. In particular
+the support for paired punctuation is only a prototype. A complete implementation
+will be added to ICU in the future.</li>
+</ul>
+
+</body>
+</html>


Property changes on: trunk/source/extra/scrptrun/readme.html
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/scrptrun/scrptrun.cpp
===================================================================
--- trunk/source/extra/scrptrun/scrptrun.cpp	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/scrptrun/scrptrun.cpp	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,202 +1,202 @@
-/*
- *******************************************************************************
- *
- *   Copyright (C) 1999-2001, International Business Machines
- *   Corporation and others.  All Rights Reserved.
- *
- *******************************************************************************
- *   file name:  scrptrun.cpp
- *
- *   created on: 10/17/2001
- *   created by: Eric R. Mader
- */
-
-#include "unicode/utypes.h"
-#include "unicode/uscript.h"
-
-#include "scrptrun.h"
-
-#define ARRAY_SIZE(array) (sizeof array  / sizeof array[0])
-
-const char ScriptRun::fgClassID=0;
-
-UChar32 ScriptRun::pairedChars[] = {
-    0x0028, 0x0029, // ascii paired punctuation
-    0x003c, 0x003e,
-    0x005b, 0x005d,
-    0x007b, 0x007d,
-    0x00ab, 0x00bb, // guillemets
-    0x2018, 0x2019, // general punctuation
-    0x201c, 0x201d,
-    0x2039, 0x203a,
-    0x3008, 0x3009, // chinese paired punctuation
-    0x300a, 0x300b,
-    0x300c, 0x300d,
-    0x300e, 0x300f,
-    0x3010, 0x3011,
-    0x3014, 0x3015,
-    0x3016, 0x3017,
-    0x3018, 0x3019,
-    0x301a, 0x301b
-};
-
-const int32_t ScriptRun::pairedCharCount = ARRAY_SIZE(pairedChars);
-const int32_t ScriptRun::pairedCharPower = 1 << highBit(pairedCharCount);
-const int32_t ScriptRun::pairedCharExtra = pairedCharCount - pairedCharPower;
-
-int8_t ScriptRun::highBit(int32_t value)
-{
-    if (value <= 0) {
-        return -32;
-    }
-
-    int8_t bit = 0;
-
-    if (value >= 1 << 16) {
-        value >>= 16;
-        bit += 16;
-    }
-
-    if (value >= 1 << 8) {
-        value >>= 8;
-        bit += 8;
-    }
-
-    if (value >= 1 << 4) {
-        value >>= 4;
-        bit += 4;
-    }
-
-    if (value >= 1 << 2) {
-        value >>= 2;
-        bit += 2;
-    }
-
-    if (value >= 1 << 1) {
-        value >>= 1;
-        bit += 1;
-    }
-
-    return bit;
-}
-
-int32_t ScriptRun::getPairIndex(UChar32 ch)
-{
-    int32_t probe = pairedCharPower;
-    int32_t index = 0;
-
-    if (ch >= pairedChars[pairedCharExtra]) {
-        index = pairedCharExtra;
-    }
-
-    while (probe > (1 << 0)) {
-        probe >>= 1;
-
-        if (ch >= pairedChars[index + probe]) {
-            index += probe;
-        }
-    }
-
-    if (pairedChars[index] != ch) {
-        index = -1;
-    }
-
-    return index;
-}
-
-UBool ScriptRun::sameScript(int32_t scriptOne, int32_t scriptTwo)
-{
-    return scriptOne <= USCRIPT_INHERITED || scriptTwo <= USCRIPT_INHERITED || scriptOne == scriptTwo;
-}
-
-UBool ScriptRun::next()
-{
-    int32_t startSP  = parenSP;  // used to find the first new open character
-    UErrorCode error = U_ZERO_ERROR;
-
-    // if we've fallen off the end of the text, we're done
-    if (scriptEnd >= charLimit) {
-        return false;
-    }
-    
-    scriptCode = USCRIPT_COMMON;
-
-    for (scriptStart = scriptEnd; scriptEnd < charLimit; scriptEnd += 1) {
-        UChar   high = charArray[scriptEnd];
-        UChar32 ch   = high;
-
-        // if the character is a high surrogate and it's not the last one
-        // in the text, see if it's followed by a low surrogate
-        if (high >= 0xD800 && high <= 0xDBFF && scriptEnd < charLimit - 1)
-        {
-            UChar low = charArray[scriptEnd + 1];
-
-            // if it is followed by a low surrogate,
-            // consume it and form the full character
-            if (low >= 0xDC00 && low <= 0xDFFF) {
-                ch = (high - 0xD800) * 0x0400 + low - 0xDC00 + 0x10000;
-                scriptEnd += 1;
-            }
-        }
-
-        UScriptCode sc = uscript_getScript(ch, &error);
-        int32_t pairIndex = getPairIndex(ch);
-
-        // Paired character handling:
-        //
-        // if it's an open character, push it onto the stack.
-        // if it's a close character, find the matching open on the
-        // stack, and use that script code. Any non-matching open
-        // characters above it on the stack will be poped.
-        if (pairIndex >= 0) {
-            if ((pairIndex & 1) == 0) {
-                parenStack[++parenSP].pairIndex = pairIndex;
-                parenStack[parenSP].scriptCode  = scriptCode;
-            } else if (parenSP >= 0) {
-                int32_t pi = pairIndex & ~1;
-
-                while (parenSP >= 0 && parenStack[parenSP].pairIndex != pi) {
-                    parenSP -= 1;
-                }
-
-                if (parenSP < startSP) {
-                    startSP = parenSP;
-                }
-
-                if (parenSP >= 0) {
-                    sc = parenStack[parenSP].scriptCode;
-                }
-            }
-        }
-
-        if (sameScript(scriptCode, sc)) {
-            if (scriptCode <= USCRIPT_INHERITED && sc > USCRIPT_INHERITED) {
-                scriptCode = sc;
-
-                // now that we have a final script code, fix any open
-                // characters we pushed before we knew the script code.
-                while (startSP < parenSP) {
-                    parenStack[++startSP].scriptCode = scriptCode;
-                }
-            }
-
-            // if this character is a close paired character,
-            // pop it from the stack
-            if (pairIndex >= 0 && (pairIndex & 1) != 0 && parenSP >= 0) {
-                parenSP -= 1;
-                startSP -= 1;
-            }
-        } else {
-            // if the run broke on a surrogate pair,
-            // end it before the high surrogate
-            if (ch >= 0x10000) {
-                scriptEnd -= 1;
-            }
-
-            break;
-        }
-    }
-
-    return true;
-}
-
+/*
+ *******************************************************************************
+ *
+ *   Copyright (C) 1999-2001, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ *******************************************************************************
+ *   file name:  scrptrun.cpp
+ *
+ *   created on: 10/17/2001
+ *   created by: Eric R. Mader
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uscript.h"
+
+#include "scrptrun.h"
+
+#define ARRAY_SIZE(array) (sizeof array  / sizeof array[0])
+
+const char ScriptRun::fgClassID=0;
+
+UChar32 ScriptRun::pairedChars[] = {
+    0x0028, 0x0029, // ascii paired punctuation
+    0x003c, 0x003e,
+    0x005b, 0x005d,
+    0x007b, 0x007d,
+    0x00ab, 0x00bb, // guillemets
+    0x2018, 0x2019, // general punctuation
+    0x201c, 0x201d,
+    0x2039, 0x203a,
+    0x3008, 0x3009, // chinese paired punctuation
+    0x300a, 0x300b,
+    0x300c, 0x300d,
+    0x300e, 0x300f,
+    0x3010, 0x3011,
+    0x3014, 0x3015,
+    0x3016, 0x3017,
+    0x3018, 0x3019,
+    0x301a, 0x301b
+};
+
+const int32_t ScriptRun::pairedCharCount = ARRAY_SIZE(pairedChars);
+const int32_t ScriptRun::pairedCharPower = 1 << highBit(pairedCharCount);
+const int32_t ScriptRun::pairedCharExtra = pairedCharCount - pairedCharPower;
+
+int8_t ScriptRun::highBit(int32_t value)
+{
+    if (value <= 0) {
+        return -32;
+    }
+
+    int8_t bit = 0;
+
+    if (value >= 1 << 16) {
+        value >>= 16;
+        bit += 16;
+    }
+
+    if (value >= 1 << 8) {
+        value >>= 8;
+        bit += 8;
+    }
+
+    if (value >= 1 << 4) {
+        value >>= 4;
+        bit += 4;
+    }
+
+    if (value >= 1 << 2) {
+        value >>= 2;
+        bit += 2;
+    }
+
+    if (value >= 1 << 1) {
+        value >>= 1;
+        bit += 1;
+    }
+
+    return bit;
+}
+
+int32_t ScriptRun::getPairIndex(UChar32 ch)
+{
+    int32_t probe = pairedCharPower;
+    int32_t index = 0;
+
+    if (ch >= pairedChars[pairedCharExtra]) {
+        index = pairedCharExtra;
+    }
+
+    while (probe > (1 << 0)) {
+        probe >>= 1;
+
+        if (ch >= pairedChars[index + probe]) {
+            index += probe;
+        }
+    }
+
+    if (pairedChars[index] != ch) {
+        index = -1;
+    }
+
+    return index;
+}
+
+UBool ScriptRun::sameScript(int32_t scriptOne, int32_t scriptTwo)
+{
+    return scriptOne <= USCRIPT_INHERITED || scriptTwo <= USCRIPT_INHERITED || scriptOne == scriptTwo;
+}
+
+UBool ScriptRun::next()
+{
+    int32_t startSP  = parenSP;  // used to find the first new open character
+    UErrorCode error = U_ZERO_ERROR;
+
+    // if we've fallen off the end of the text, we're done
+    if (scriptEnd >= charLimit) {
+        return false;
+    }
+    
+    scriptCode = USCRIPT_COMMON;
+
+    for (scriptStart = scriptEnd; scriptEnd < charLimit; scriptEnd += 1) {
+        UChar   high = charArray[scriptEnd];
+        UChar32 ch   = high;
+
+        // if the character is a high surrogate and it's not the last one
+        // in the text, see if it's followed by a low surrogate
+        if (high >= 0xD800 && high <= 0xDBFF && scriptEnd < charLimit - 1)
+        {
+            UChar low = charArray[scriptEnd + 1];
+
+            // if it is followed by a low surrogate,
+            // consume it and form the full character
+            if (low >= 0xDC00 && low <= 0xDFFF) {
+                ch = (high - 0xD800) * 0x0400 + low - 0xDC00 + 0x10000;
+                scriptEnd += 1;
+            }
+        }
+
+        UScriptCode sc = uscript_getScript(ch, &error);
+        int32_t pairIndex = getPairIndex(ch);
+
+        // Paired character handling:
+        //
+        // if it's an open character, push it onto the stack.
+        // if it's a close character, find the matching open on the
+        // stack, and use that script code. Any non-matching open
+        // characters above it on the stack will be poped.
+        if (pairIndex >= 0) {
+            if ((pairIndex & 1) == 0) {
+                parenStack[++parenSP].pairIndex = pairIndex;
+                parenStack[parenSP].scriptCode  = scriptCode;
+            } else if (parenSP >= 0) {
+                int32_t pi = pairIndex & ~1;
+
+                while (parenSP >= 0 && parenStack[parenSP].pairIndex != pi) {
+                    parenSP -= 1;
+                }
+
+                if (parenSP < startSP) {
+                    startSP = parenSP;
+                }
+
+                if (parenSP >= 0) {
+                    sc = parenStack[parenSP].scriptCode;
+                }
+            }
+        }
+
+        if (sameScript(scriptCode, sc)) {
+            if (scriptCode <= USCRIPT_INHERITED && sc > USCRIPT_INHERITED) {
+                scriptCode = sc;
+
+                // now that we have a final script code, fix any open
+                // characters we pushed before we knew the script code.
+                while (startSP < parenSP) {
+                    parenStack[++startSP].scriptCode = scriptCode;
+                }
+            }
+
+            // if this character is a close paired character,
+            // pop it from the stack
+            if (pairIndex >= 0 && (pairIndex & 1) != 0 && parenSP >= 0) {
+                parenSP -= 1;
+                startSP -= 1;
+            }
+        } else {
+            // if the run broke on a surrogate pair,
+            // end it before the high surrogate
+            if (ch >= 0x10000) {
+                scriptEnd -= 1;
+            }
+
+            break;
+        }
+    }
+
+    return true;
+}
+


Property changes on: trunk/source/extra/scrptrun/scrptrun.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/scrptrun/scrptrun.h
===================================================================
--- trunk/source/extra/scrptrun/scrptrun.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/scrptrun/scrptrun.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,154 +1,154 @@
-/*
- *******************************************************************************
- *
- *   Copyright (C) 1999-2003, International Business Machines
- *   Corporation and others.  All Rights Reserved.
- *
- *******************************************************************************
- *   file name:  scrptrun.h
- *
- *   created on: 10/17/2001
- *   created by: Eric R. Mader
- */
-
-#ifndef __SCRPTRUN_H
-#define __SCRPTRUN_H
-
-#include "unicode/utypes.h"
-#include "unicode/uobject.h"
-#include "unicode/uscript.h"
-
-struct ScriptRecord
-{
-    UChar32 startChar;
-    UChar32 endChar;
-    UScriptCode scriptCode;
-};
-
-struct ParenStackEntry
-{
-    int32_t pairIndex;
-    UScriptCode scriptCode;
-};
-
-class ScriptRun : public UObject {
-public:
-    ScriptRun();
-
-    ScriptRun(const UChar chars[], int32_t length);
-
-    ScriptRun(const UChar chars[], int32_t start, int32_t length);
-
-    void reset();
-
-    void reset(int32_t start, int32_t count);
-
-    void reset(const UChar chars[], int32_t start, int32_t length);
-
-    int32_t getScriptStart();
-
-    int32_t getScriptEnd();
-
-    UScriptCode getScriptCode();
-
-    UBool next();
-
-    /**
-     * ICU "poor man's RTTI", returns a UClassID for the actual class.
-     *
-     * @stable ICU 2.2
-     */
-    virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
-
-    /**
-     * ICU "poor man's RTTI", returns a UClassID for this class.
-     *
-     * @stable ICU 2.2
-     */
-    static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
-
-private:
-
-    static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
-
-    int32_t charStart;
-    int32_t charLimit;
-    const UChar *charArray;
-
-    int32_t scriptStart;
-    int32_t scriptEnd;
-    UScriptCode scriptCode;
-
-    ParenStackEntry parenStack[128];
-    int32_t parenSP;
-
-    static int8_t highBit(int32_t value);
-    static int32_t getPairIndex(UChar32 ch);
-
-    static UChar32 pairedChars[];
-    static const int32_t pairedCharCount;
-    static const int32_t pairedCharPower;
-    static const int32_t pairedCharExtra;
-
-    /**
-     * The address of this static class variable serves as this class's ID
-     * for ICU "poor man's RTTI".
-     */
-    static const char fgClassID;
-};
-
-inline ScriptRun::ScriptRun()
-{
-    reset(NULL, 0, 0);
-}
-
-inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
-{
-    reset(chars, 0, length);
-}
-
-inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
-{
-    reset(chars, start, length);
-}
-
-inline int32_t ScriptRun::getScriptStart()
-{
-    return scriptStart;
-}
-
-inline int32_t ScriptRun::getScriptEnd()
-{
-    return scriptEnd;
-}
-
-inline UScriptCode ScriptRun::getScriptCode()
-{
-    return scriptCode;
-}
-
-inline void ScriptRun::reset()
-{
-    scriptStart = charStart;
-    scriptEnd   = charStart;
-    scriptCode  = USCRIPT_INVALID_CODE;
-    parenSP     = -1;
-}
-
-inline void ScriptRun::reset(int32_t start, int32_t length)
-{
-    charStart = start;
-    charLimit = start + length;
-
-    reset();
-}
-
-inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
-{
-    charArray = chars;
-
-    reset(start, length);
-}
-
-
-#endif
+/*
+ *******************************************************************************
+ *
+ *   Copyright (C) 1999-2003, International Business Machines
+ *   Corporation and others.  All Rights Reserved.
+ *
+ *******************************************************************************
+ *   file name:  scrptrun.h
+ *
+ *   created on: 10/17/2001
+ *   created by: Eric R. Mader
+ */
+
+#ifndef __SCRPTRUN_H
+#define __SCRPTRUN_H
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/uscript.h"
+
+struct ScriptRecord
+{
+    UChar32 startChar;
+    UChar32 endChar;
+    UScriptCode scriptCode;
+};
+
+struct ParenStackEntry
+{
+    int32_t pairIndex;
+    UScriptCode scriptCode;
+};
+
+class ScriptRun : public UObject {
+public:
+    ScriptRun();
+
+    ScriptRun(const UChar chars[], int32_t length);
+
+    ScriptRun(const UChar chars[], int32_t start, int32_t length);
+
+    void reset();
+
+    void reset(int32_t start, int32_t count);
+
+    void reset(const UChar chars[], int32_t start, int32_t length);
+
+    int32_t getScriptStart();
+
+    int32_t getScriptEnd();
+
+    UScriptCode getScriptCode();
+
+    UBool next();
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     *
+     * @stable ICU 2.2
+     */
+    virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
+
+    /**
+     * ICU "poor man's RTTI", returns a UClassID for this class.
+     *
+     * @stable ICU 2.2
+     */
+    static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
+
+private:
+
+    static UBool sameScript(int32_t scriptOne, int32_t scriptTwo);
+
+    int32_t charStart;
+    int32_t charLimit;
+    const UChar *charArray;
+
+    int32_t scriptStart;
+    int32_t scriptEnd;
+    UScriptCode scriptCode;
+
+    ParenStackEntry parenStack[128];
+    int32_t parenSP;
+
+    static int8_t highBit(int32_t value);
+    static int32_t getPairIndex(UChar32 ch);
+
+    static UChar32 pairedChars[];
+    static const int32_t pairedCharCount;
+    static const int32_t pairedCharPower;
+    static const int32_t pairedCharExtra;
+
+    /**
+     * The address of this static class variable serves as this class's ID
+     * for ICU "poor man's RTTI".
+     */
+    static const char fgClassID;
+};
+
+inline ScriptRun::ScriptRun()
+{
+    reset(NULL, 0, 0);
+}
+
+inline ScriptRun::ScriptRun(const UChar chars[], int32_t length)
+{
+    reset(chars, 0, length);
+}
+
+inline ScriptRun::ScriptRun(const UChar chars[], int32_t start, int32_t length)
+{
+    reset(chars, start, length);
+}
+
+inline int32_t ScriptRun::getScriptStart()
+{
+    return scriptStart;
+}
+
+inline int32_t ScriptRun::getScriptEnd()
+{
+    return scriptEnd;
+}
+
+inline UScriptCode ScriptRun::getScriptCode()
+{
+    return scriptCode;
+}
+
+inline void ScriptRun::reset()
+{
+    scriptStart = charStart;
+    scriptEnd   = charStart;
+    scriptCode  = USCRIPT_INVALID_CODE;
+    parenSP     = -1;
+}
+
+inline void ScriptRun::reset(int32_t start, int32_t length)
+{
+    charStart = start;
+    charLimit = start + length;
+
+    reset();
+}
+
+inline void ScriptRun::reset(const UChar chars[], int32_t start, int32_t length)
+{
+    charArray = chars;
+
+    reset(start, length);
+}
+
+
+#endif


Property changes on: trunk/source/extra/scrptrun/scrptrun.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/scrptrun/srtest.cpp
===================================================================
--- trunk/source/extra/scrptrun/srtest.cpp	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/scrptrun/srtest.cpp	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,38 +1,38 @@
-/*
- * %W% %E%
- *
- * (C) Copyright IBM Corp. 2001 - All Rights Reserved
- *
- */
-
-#include "unicode/utypes.h"
-#include "unicode/uscript.h"
-
-#include "scrptrun.h"
-
-#include <stdio.h>
-
-UChar testChars[] = {
-            0x0020, 0x0946, 0x0939, 0x093F, 0x0928, 0x094D, 0x0926, 0x0940, 0x0020,
-            0x0627, 0x0644, 0x0639, 0x0631, 0x0628, 0x064A, 0x0629, 0x0020,
-            0x0420, 0x0443, 0x0441, 0x0441, 0x043A, 0x0438, 0x0439, 0x0020,
-            'E', 'n', 'g', 'l', 'i', 's', 'h',  0x0020,
-            0x6F22, 0x5B75, 0x3068, 0x3072, 0x3089, 0x304C, 0x306A, 0x3068, 
-            0x30AB, 0x30BF, 0x30AB, 0x30CA,
-            0xD801, 0xDC00, 0xD801, 0xDC01, 0xD801, 0xDC02, 0xD801, 0xDC03
-};
-
-int32_t testLength = sizeof testChars / sizeof testChars[0];
-
-void main()
-{
-    ScriptRun scriptRun(testChars, 0, testLength);
-
-    while (scriptRun.next()) {
-        int32_t     start = scriptRun.getScriptStart();
-        int32_t     end   = scriptRun.getScriptEnd();
-        UScriptCode code  = scriptRun.getScriptCode();
-
-        printf("Script '%s' from %d to %d.\n", uscript_getName(code), start, end);
-    }
+/*
+ * %W% %E%
+ *
+ * (C) Copyright IBM Corp. 2001 - All Rights Reserved
+ *
+ */
+
+#include "unicode/utypes.h"
+#include "unicode/uscript.h"
+
+#include "scrptrun.h"
+
+#include <stdio.h>
+
+UChar testChars[] = {
+            0x0020, 0x0946, 0x0939, 0x093F, 0x0928, 0x094D, 0x0926, 0x0940, 0x0020,
+            0x0627, 0x0644, 0x0639, 0x0631, 0x0628, 0x064A, 0x0629, 0x0020,
+            0x0420, 0x0443, 0x0441, 0x0441, 0x043A, 0x0438, 0x0439, 0x0020,
+            'E', 'n', 'g', 'l', 'i', 's', 'h',  0x0020,
+            0x6F22, 0x5B75, 0x3068, 0x3072, 0x3089, 0x304C, 0x306A, 0x3068, 
+            0x30AB, 0x30BF, 0x30AB, 0x30CA,
+            0xD801, 0xDC00, 0xD801, 0xDC01, 0xD801, 0xDC02, 0xD801, 0xDC03
+};
+
+int32_t testLength = sizeof testChars / sizeof testChars[0];
+
+void main()
+{
+    ScriptRun scriptRun(testChars, 0, testLength);
+
+    while (scriptRun.next()) {
+        int32_t     start = scriptRun.getScriptStart();
+        int32_t     end   = scriptRun.getScriptEnd();
+        UScriptCode code  = scriptRun.getScriptCode();
+
+        printf("Script '%s' from %d to %d.\n", uscript_getName(code), start, end);
+    }
 }
\ No newline at end of file


Property changes on: trunk/source/extra/scrptrun/srtest.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/Makefile.in
===================================================================
--- trunk/source/extra/uconv/Makefile.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/Makefile.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,170 +1,170 @@
-## ******************************************************************************
-## *
-## *   Copyright (C) 1999-2006, International Business Machines
-## *   Corporation and others.  All Rights Reserved.
-## *
-## *******************************************************************************
-## Makefile.in for ICU - uconv
-## Steven  R. Loomis
-
-## Set the following to dll or static or common..
-UCONVMSG_MODE=static
-##############################################################
-
-srcdir=@srcdir@
-top_srcdir=@top_srcdir@
-
-top_builddir = ../..
-subdir = extra/uconv
-
-include $(top_builddir)/icudefs.mk
-
-MSGNAME=uconvmsg
-
-# RESSRC comes from resfiles.mk
-FILESEPCHAR=/
-include $(srcdir)/resfiles.mk
-
-RESDIR=$(MSGNAME)
-RESFILES=$(RESSRC:$(RESOURCESDIR)$(FILESEPCHAR)%.txt=$(RESDIR)/%.res)
-
-##
-
-TARGET_STUB_NAME = uconv
-
-SECTION = 1
-
-ALL_MAN_FILES = $(TARGET_STUB_NAME).$(SECTION)
-
-## Extra files to remove for 'make clean'
-CLEANFILES = *~ $(DEPS) $(ALL_MAN_FILES)
-
-## Target information
-TARGET = $(BINDIR)/$(TARGET_STUB_NAME)$(EXEEXT)
-
-CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(srcdir)/../toolutil
-LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
-
-ifeq ($(PKGDATA_OPTS),)
-PKGDATA_OPTS = -O pkgdata.inc
-endif
-
-## generic settings for data - common.
-PKGMODE=common
-INSTALLTO=$(DESTDIR)$(ICUDATA_DIR)
-UCONVMSG_LIB=dummy
-
-## Static mode
-ifeq ($(UCONVMSG_MODE),static)
-DEFS += -DUCONVMSG_LINK=$(MSGNAME)
-UCONVMSG_LIB = $(RESDIR)/$(LIBPREFIX)$(MSGNAME).$(A)
-LIBS += $(UCONVMSG_LIB)
-PKGMODE=static
-INSTALLTO=$(libdir)
-endif
-
-## DLL mode
-ifeq ($(UCONVMSG_MODE),dll)
-DEFS += -DUCONVMSG_LINK=$(MSGNAME)
-LIBS += -L$(RESDIR) -l$(MSGNAME)
-PKGMODE=dll
-INSTALLTO=$(libdir)
-endif
-
-OBJECTS = uconv.o uwmsg.o
-
-DEPS = $(OBJECTS:.o=.d)
-
-## List of phony targets
-.PHONY : all all-local install install-local clean clean-local \
-distclean resclean distclean-local dist dist-local check check-local resfiles package-resfiles install-resfiles install-man
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-local
-
-install: install-local
-clean: clean-local
-distclean : distclean-local
-dist: dist-local
-check: check-local
-
-all-local: $(TARGET) resfiles $(ALL_MAN_FILES)
-
-install-local: all-local install-target install-resfiles install-man
-
-install-target: all-local
-	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
-	$(INSTALL) $(TARGET) $(DESTDIR)$(bindir)
-
-dist-local:
-
-clean-local: resclean
-	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) $(RESFILES)
-	$(RMV) $(OBJECTS) $(TARGET)
-
-resclean:
-	@#-$(INVOKE) $(BINDIR)/pkgdata --clean -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
-	$(RMV) pkgdata.inc $(RESDIR)
-
-distclean-local: clean-local
-	$(RMV) Makefile $(DEPS)
-
-check-local:
-
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	cd $(top_builddir) \
-	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-pkgdata.inc: $(srcdir)/pkgdata.inc.in $(top_builddir)/config.status
-	cd $(top_builddir) \
-	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(TARGET_STUB_NAME).$(SECTION): $(srcdir)/$(TARGET_STUB_NAME).$(SECTION).in pkgdata.inc
-	cd $(top_builddir) \
-	 && CONFIG_FILES=$(subdir)/$(TARGET_STUB_NAME).$(SECTION) CONFIG_HEADERS= $(SHELL) ./config.status
-
-$(TARGET) : $(OBJECTS)  $(UCONVMSG_LIB)
-	$(LINK.cc) $(OUTOPT)$@ $(OBJECTS) $(LIBS)
-
-resfiles: $(RESFILES) package-resfiles
-
-ifeq ($(UCONVMSG_STATIC),YES)
-$(UCONVMSG_LIB): resfiles
-endif
-
-
-package-resfiles: $(RESDIR)/$(RESDIR).lst pkgdata.inc
-	$(INVOKE) $(PKGDATA_INVOKE_OPTS) $(BINDIR)/pkgdata -p $(MSGNAME) $(PKGDATA_OPTS) -m $(PKGMODE) -s $(RESDIR) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
-
-$(RESDIR)/$(RESDIR).lst: Makefile $(srcdir)/resfiles.mk
-	@$(MKINSTALLDIRS) $(RESDIR)
-	@-$(RMV) $@
-	@for file in $(RESFILES:$(RESDIR)/%.res=%.res); do \
-	  echo $$file >> $@; \
-	done;
-
-# no install for static mode
-ifneq ($(UCONVMSG_MODE),static)
-install-resfiles: $(RESFILES)
-	$(MKINSTALLDIRS) $(DESTDIR)$(ICUDATA_DIR)
-	$(INVOKE) $(BINDIR)/pkgdata -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -I $(INSTALLTO) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
-else
-install-resfiles:
-endif
-
-##
-$(UCONVMSG_LIB): resfiles
-
-$(MSGNAME)/%.res: $(srcdir)/$(RESOURCESDIR)/%.txt
-	$(MKINSTALLDIRS) $(@D)
-	$(INVOKE) $(BINDIR)/genrb -e UTF-8 -s $(^D) -d $(@D) $(^F)
-
-install-man: $(ALL_MAN_FILES)
-	$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION)
-	$(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION)
-
-
-
+## ******************************************************************************
+## *
+## *   Copyright (C) 1999-2006, International Business Machines
+## *   Corporation and others.  All Rights Reserved.
+## *
+## *******************************************************************************
+## Makefile.in for ICU - uconv
+## Steven  R. Loomis
+
+## Set the following to dll or static or common..
+UCONVMSG_MODE=static
+##############################################################
+
+srcdir=@srcdir@
+top_srcdir=@top_srcdir@
+
+top_builddir = ../..
+subdir = extra/uconv
+
+include $(top_builddir)/icudefs.mk
+
+MSGNAME=uconvmsg
+
+# RESSRC comes from resfiles.mk
+FILESEPCHAR=/
+include $(srcdir)/resfiles.mk
+
+RESDIR=$(MSGNAME)
+RESFILES=$(RESSRC:$(RESOURCESDIR)$(FILESEPCHAR)%.txt=$(RESDIR)/%.res)
+
+##
+
+TARGET_STUB_NAME = uconv
+
+SECTION = 1
+
+ALL_MAN_FILES = $(TARGET_STUB_NAME).$(SECTION)
+
+## Extra files to remove for 'make clean'
+CLEANFILES = *~ $(DEPS) $(ALL_MAN_FILES)
+
+## Target information
+TARGET = $(BINDIR)/$(TARGET_STUB_NAME)$(EXEEXT)
+
+CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(srcdir)/../toolutil
+LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
+
+ifeq ($(PKGDATA_OPTS),)
+PKGDATA_OPTS = -O pkgdata.inc
+endif
+
+## generic settings for data - common.
+PKGMODE=common
+INSTALLTO=$(DESTDIR)$(ICUDATA_DIR)
+UCONVMSG_LIB=dummy
+
+## Static mode
+ifeq ($(UCONVMSG_MODE),static)
+DEFS += -DUCONVMSG_LINK=$(MSGNAME)
+UCONVMSG_LIB = $(RESDIR)/$(LIBPREFIX)$(MSGNAME).$(A)
+LIBS += $(UCONVMSG_LIB)
+PKGMODE=static
+INSTALLTO=$(libdir)
+endif
+
+## DLL mode
+ifeq ($(UCONVMSG_MODE),dll)
+DEFS += -DUCONVMSG_LINK=$(MSGNAME)
+LIBS += -L$(RESDIR) -l$(MSGNAME)
+PKGMODE=dll
+INSTALLTO=$(libdir)
+endif
+
+OBJECTS = uconv.o uwmsg.o
+
+DEPS = $(OBJECTS:.o=.d)
+
+## List of phony targets
+.PHONY : all all-local install install-local clean clean-local \
+distclean resclean distclean-local dist dist-local check check-local resfiles package-resfiles install-resfiles install-man
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-local
+
+install: install-local
+clean: clean-local
+distclean : distclean-local
+dist: dist-local
+check: check-local
+
+all-local: $(TARGET) resfiles $(ALL_MAN_FILES)
+
+install-local: all-local install-target install-resfiles install-man
+
+install-target: all-local
+	$(MKINSTALLDIRS) $(DESTDIR)$(bindir)
+	$(INSTALL) $(TARGET) $(DESTDIR)$(bindir)
+
+dist-local:
+
+clean-local: resclean
+	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES) $(RESFILES)
+	$(RMV) $(OBJECTS) $(TARGET)
+
+resclean:
+	@#-$(INVOKE) $(BINDIR)/pkgdata --clean -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
+	$(RMV) pkgdata.inc $(RESDIR)
+
+distclean-local: clean-local
+	$(RMV) Makefile $(DEPS)
+
+check-local:
+
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	cd $(top_builddir) \
+	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+pkgdata.inc: $(srcdir)/pkgdata.inc.in $(top_builddir)/config.status
+	cd $(top_builddir) \
+	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(TARGET_STUB_NAME).$(SECTION): $(srcdir)/$(TARGET_STUB_NAME).$(SECTION).in pkgdata.inc
+	cd $(top_builddir) \
+	 && CONFIG_FILES=$(subdir)/$(TARGET_STUB_NAME).$(SECTION) CONFIG_HEADERS= $(SHELL) ./config.status
+
+$(TARGET) : $(OBJECTS)  $(UCONVMSG_LIB)
+	$(LINK.cc) $(OUTOPT)$@ $(OBJECTS) $(LIBS)
+
+resfiles: $(RESFILES) package-resfiles
+
+ifeq ($(UCONVMSG_STATIC),YES)
+$(UCONVMSG_LIB): resfiles
+endif
+
+
+package-resfiles: $(RESDIR)/$(RESDIR).lst pkgdata.inc
+	$(INVOKE) $(PKGDATA_INVOKE_OPTS) $(BINDIR)/pkgdata -p $(MSGNAME) $(PKGDATA_OPTS) -m $(PKGMODE) -s $(RESDIR) -d $(RESDIR) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
+
+$(RESDIR)/$(RESDIR).lst: Makefile $(srcdir)/resfiles.mk
+	@$(MKINSTALLDIRS) $(RESDIR)
+	@-$(RMV) $@
+	@for file in $(RESFILES:$(RESDIR)/%.res=%.res); do \
+	  echo $$file >> $@; \
+	done;
+
+# no install for static mode
+ifneq ($(UCONVMSG_MODE),static)
+install-resfiles: $(RESFILES)
+	$(MKINSTALLDIRS) $(DESTDIR)$(ICUDATA_DIR)
+	$(INVOKE) $(BINDIR)/pkgdata -p $(RESDIR) -O pkgdata.inc -m $(PKGMODE) -d $(RESDIR) -I $(INSTALLTO) -T $(RESDIR) $(RESDIR)/$(RESDIR).lst
+else
+install-resfiles:
+endif
+
+##
+$(UCONVMSG_LIB): resfiles
+
+$(MSGNAME)/%.res: $(srcdir)/$(RESOURCESDIR)/%.txt
+	$(MKINSTALLDIRS) $(@D)
+	$(INVOKE) $(BINDIR)/genrb -e UTF-8 -s $(^D) -d $(@D) $(^F)
+
+install-man: $(ALL_MAN_FILES)
+	$(MKINSTALLDIRS) $(DESTDIR)$(mandir)/man$(SECTION)
+	$(INSTALL_DATA) $? $(DESTDIR)$(mandir)/man$(SECTION)
+
+
+


Property changes on: trunk/source/extra/uconv/Makefile.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/README
===================================================================
--- trunk/source/extra/uconv/README	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/README	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,15 +1,15 @@
-Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.
-
-The uconv command is an iconv(1)-like conversion / transcoding
-program. Please check its manual page, or run uconv -h, for help.
-
-Help, as well as error messages, are displayed through the use of a
-resource bundle. Please contact Steven Loomis <srl at jtcsv.com> if you
-want to offer a translation of these messages for a particular locale.
-
-uconv was originally written and contributed to icuapps by Jonas Utterström
-<jonas.utterstrom at vittran.norrnod.se>, and offered simple conversion and
-a way to know which encodings were available. It has since then be
-moved to the main ICU distribution and converted to the C conversion
-API, and is maintained by Yves Arrouye <yves at realnames.com> who seems
-to always be looking for one more feature or option to add to the tool.
+Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.
+
+The uconv command is an iconv(1)-like conversion / transcoding
+program. Please check its manual page, or run uconv -h, for help.
+
+Help, as well as error messages, are displayed through the use of a
+resource bundle. Please contact Steven Loomis <srl at jtcsv.com> if you
+want to offer a translation of these messages for a particular locale.
+
+uconv was originally written and contributed to icuapps by Jonas Utterström
+<jonas.utterstrom at vittran.norrnod.se>, and offered simple conversion and
+a way to know which encodings were available. It has since then be
+moved to the main ICU distribution and converted to the C conversion
+API, and is maintained by Yves Arrouye <yves at realnames.com> who seems
+to always be looking for one more feature or option to add to the tool.


Property changes on: trunk/source/extra/uconv/README
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/makedata.mak
===================================================================
--- trunk/source/extra/uconv/makedata.mak	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/makedata.mak	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,102 +1,102 @@
-#**********************************************************************
-#* Copyright (C) 1999-2004, International Business Machines Corporation
-#* and others.  All Rights Reserved.
-#**********************************************************************
-# nmake file for creating data files on win32
-# invoke with
-# nmake /f makedata.mak icup=<path_to_icu_instalation> [Debug|Release]
-#
-#	12/10/1999	weiv	Created
-
-#If no config, we default to debug
-!IF "$(CFG)" == ""
-CFG=Debug
-!MESSAGE No configuration specified. Defaulting to common - Win32 Debug.
-!ENDIF
-
-#Here we test if a valid configuration is given
-!IF "$(CFG)" != "Release" && "$(CFG)" != "release" && "$(CFG)" != "Debug" && "$(CFG)" != "debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "makedata.mak" CFG="Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "Release"
-!MESSAGE "Debug"
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-#Let's see if user has given us a path to ICU
-#This could be found according to the path to makefile, but for now it is this way
-!IF "$(ICUP)"==""
-!ERROR Can't find path!
-!ENDIF
-!MESSAGE ICU path is $(ICUP)
-RESNAME=uconvmsg
-RESDIR=resources
-RESFILES=resfiles.mk
-ICUDATA=$(ICUP)\data
-
-DLL_OUTPUT=.\$(CFG)
-# set the following to 'static' or 'dll' depending
-PKGMODE=static
-
-
-ICD=$(ICUDATA)^\
-DATA_PATH=$(ICUP)\data^\
-ICUTOOLS=$(ICUP)\bin
-
-PATH = $(ICUP)\bin;$(PATH)
-
-# Suffixes for data files
-.SUFFIXES : .ucm .cnv .dll .dat .res .txt .c
-
-# We're including a list of resource files.
-FILESEPCHAR=
-
-!IF EXISTS("$(RESFILES)")
-!INCLUDE "$(RESFILES)"
-!ELSE
-!ERROR ERROR: cannot find "$(RESFILES)"
-!ENDIF
-RB_FILES = $(RESSRC:.txt=.res)
-RB_FILES = resources\$(RB_FILES:.res =.res resources\)
-RESOURCESDIR=
-
-# This target should build all the data files
-!IF "$(PKGMODE)" == "dll"
-OUTPUT = "$(DLL_OUTPUT)\$(RESNAME).dll"
-!ELSE
-OUTPUT = "$(DLL_OUTPUT)\$(RESNAME).lib"
-!ENDIF
-
-ALL : $(OUTPUT)
-	@echo All targets are up to date (mode $(PKGMODE))
-
-
-# invoke pkgdata - static
-"$(DLL_OUTPUT)\$(RESNAME).lib" : $(RB_FILES) $(RESFILES)
-	@echo Building $(RESNAME).lib
-	@"$(ICUTOOLS)\pkgdata" -f -v -m static -c -p $(RESNAME) -d "$(DLL_OUTPUT)" -s "$(RESDIR)" <<pkgdatain.txt
-$(RESSRC:.txt =.res
-)
-<<KEEP
-
-# This is to remove all the data files
-CLEAN :
-    - at erase "$(RB_FILES)"
-	- at erase "$(CFG)\*uconvmsg*.*"
-    -@"$(ICUTOOLS)\pkgdata" -f --clean -v -m static -c -p $(RESNAME) -d "$(DLL_OUTPUT)" -s "$(RESDIR)" pkgdatain.txt
-
-# Inference rule for creating resource bundles
-{$(RESDIR)}.txt{$(RESDIR)}.res:
-	@echo Making Resource Bundle files
-	"$(ICUTOOLS)\genrb" -s $(@D) -d $(@D) $(?F)
-
-
-$(RESSRC) : {"$(ICUTOOLS)"}genrb.exe
-
+#**********************************************************************
+#* Copyright (C) 1999-2004, International Business Machines Corporation
+#* and others.  All Rights Reserved.
+#**********************************************************************
+# nmake file for creating data files on win32
+# invoke with
+# nmake /f makedata.mak icup=<path_to_icu_instalation> [Debug|Release]
+#
+#	12/10/1999	weiv	Created
+
+#If no config, we default to debug
+!IF "$(CFG)" == ""
+CFG=Debug
+!MESSAGE No configuration specified. Defaulting to common - Win32 Debug.
+!ENDIF
+
+#Here we test if a valid configuration is given
+!IF "$(CFG)" != "Release" && "$(CFG)" != "release" && "$(CFG)" != "Debug" && "$(CFG)" != "debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "makedata.mak" CFG="Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "Release"
+!MESSAGE "Debug"
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+#Let's see if user has given us a path to ICU
+#This could be found according to the path to makefile, but for now it is this way
+!IF "$(ICUP)"==""
+!ERROR Can't find path!
+!ENDIF
+!MESSAGE ICU path is $(ICUP)
+RESNAME=uconvmsg
+RESDIR=resources
+RESFILES=resfiles.mk
+ICUDATA=$(ICUP)\data
+
+DLL_OUTPUT=.\$(CFG)
+# set the following to 'static' or 'dll' depending
+PKGMODE=static
+
+
+ICD=$(ICUDATA)^\
+DATA_PATH=$(ICUP)\data^\
+ICUTOOLS=$(ICUP)\bin
+
+PATH = $(ICUP)\bin;$(PATH)
+
+# Suffixes for data files
+.SUFFIXES : .ucm .cnv .dll .dat .res .txt .c
+
+# We're including a list of resource files.
+FILESEPCHAR=
+
+!IF EXISTS("$(RESFILES)")
+!INCLUDE "$(RESFILES)"
+!ELSE
+!ERROR ERROR: cannot find "$(RESFILES)"
+!ENDIF
+RB_FILES = $(RESSRC:.txt=.res)
+RB_FILES = resources\$(RB_FILES:.res =.res resources\)
+RESOURCESDIR=
+
+# This target should build all the data files
+!IF "$(PKGMODE)" == "dll"
+OUTPUT = "$(DLL_OUTPUT)\$(RESNAME).dll"
+!ELSE
+OUTPUT = "$(DLL_OUTPUT)\$(RESNAME).lib"
+!ENDIF
+
+ALL : $(OUTPUT)
+	@echo All targets are up to date (mode $(PKGMODE))
+
+
+# invoke pkgdata - static
+"$(DLL_OUTPUT)\$(RESNAME).lib" : $(RB_FILES) $(RESFILES)
+	@echo Building $(RESNAME).lib
+	@"$(ICUTOOLS)\pkgdata" -f -v -m static -c -p $(RESNAME) -d "$(DLL_OUTPUT)" -s "$(RESDIR)" <<pkgdatain.txt
+$(RESSRC:.txt =.res
+)
+<<KEEP
+
+# This is to remove all the data files
+CLEAN :
+    - at erase "$(RB_FILES)"
+	- at erase "$(CFG)\*uconvmsg*.*"
+    -@"$(ICUTOOLS)\pkgdata" -f --clean -v -m static -c -p $(RESNAME) -d "$(DLL_OUTPUT)" -s "$(RESDIR)" pkgdatain.txt
+
+# Inference rule for creating resource bundles
+{$(RESDIR)}.txt{$(RESDIR)}.res:
+	@echo Making Resource Bundle files
+	"$(ICUTOOLS)\genrb" -s $(@D) -d $(@D) $(?F)
+
+
+$(RESSRC) : {"$(ICUTOOLS)"}genrb.exe
+


Property changes on: trunk/source/extra/uconv/makedata.mak
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/pkgdata.inc.in
===================================================================
--- trunk/source/extra/uconv/pkgdata.inc.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/pkgdata.inc.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,64 +1,64 @@
-#******************************************************************************
-#
-#   Copyright (C) 2000-2004, International Business Machines
-#   Corporation and others.  All Rights Reserved.
-#
-#******************************************************************************
-# This Makefile is used to build the ICU's data.
-# It is included with the -O option to pkgdata.
-
-PLATFORM=@platform@
-
-top_srcdir=@top_srcdir@
-srcdir=@srcdir@
-top_builddir=../..
-
-include $(top_builddir)/icudefs.mk
-
-CPPFLAGS+= -I$(top_builddir)/common -I$(top_srcdir)/common
-LIBS=@LIBS@ 
-exec_prefix=@exec_prefix@
-prefix=@prefix@
-program_transform_name=@program_transform_name@
-bindir=@bindir@
-sbindir=@sbindir@
-libexecdir=@libexecdir@
-datadir=@datadir@
-sysconfdir=@sysconfdir@
-sharedstatedir=@sharedstatedir@
-localstatedir=@localstatedir@
-libdir=@libdir@
-includedir=@includedir@
-oldincludedir=@oldincludedir@
-infodir=@infodir@
-mandir=@mandir@
-PACKAGE=@PACKAGE@
-VERSION=@VERSION@
-
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
-INSTALL_PROGRAM=@INSTALL_PROGRAM@
-INSTALL_SCRIPT=@INSTALL_SCRIPT@
-INSTALL_DATA=@INSTALL_DATA@
-host=@host@
-host_alias=@host_alias@
-host_cpu=@host_cpu@
-host_vendor=@host_vendor@
-host_os=@host_os@
-LIB_M=@LIB_M@
-CPP=@CPP@
-U_HAVE_INTTYPES_H=@U_HAVE_INTTYPES_H@
-U_IS_BIG_ENDIAN=@U_IS_BIG_ENDIAN@
-platform=@platform@
-
-
-ld_rpath_suf=@ld_rpath_suf@
-
-##### Add the following to source/config/Makefile.in
-
-GENCCODE=$(BINDIR)/genccode
-GENCMN=$(BINDIR)/gencmn
-
-
+#******************************************************************************
+#
+#   Copyright (C) 2000-2004, International Business Machines
+#   Corporation and others.  All Rights Reserved.
+#
+#******************************************************************************
+# This Makefile is used to build the ICU's data.
+# It is included with the -O option to pkgdata.
+
+PLATFORM=@platform@
+
+top_srcdir=@top_srcdir@
+srcdir=@srcdir@
+top_builddir=../..
+
+include $(top_builddir)/icudefs.mk
+
+CPPFLAGS+= -I$(top_builddir)/common -I$(top_srcdir)/common
+LIBS=@LIBS@ 
+exec_prefix=@exec_prefix@
+prefix=@prefix@
+program_transform_name=@program_transform_name@
+bindir=@bindir@
+sbindir=@sbindir@
+libexecdir=@libexecdir@
+datadir=@datadir@
+sysconfdir=@sysconfdir@
+sharedstatedir=@sharedstatedir@
+localstatedir=@localstatedir@
+libdir=@libdir@
+includedir=@includedir@
+oldincludedir=@oldincludedir@
+infodir=@infodir@
+mandir=@mandir@
+PACKAGE=@PACKAGE@
+VERSION=@VERSION@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+INSTALL_PROGRAM=@INSTALL_PROGRAM@
+INSTALL_SCRIPT=@INSTALL_SCRIPT@
+INSTALL_DATA=@INSTALL_DATA@
+host=@host@
+host_alias=@host_alias@
+host_cpu=@host_cpu@
+host_vendor=@host_vendor@
+host_os=@host_os@
+LIB_M=@LIB_M@
+CPP=@CPP@
+U_HAVE_INTTYPES_H=@U_HAVE_INTTYPES_H@
+U_IS_BIG_ENDIAN=@U_IS_BIG_ENDIAN@
+platform=@platform@
+
+
+ld_rpath_suf=@ld_rpath_suf@
+
+##### Add the following to source/config/Makefile.in
+
+GENCCODE=$(BINDIR)/genccode
+GENCMN=$(BINDIR)/gencmn
+
+


Property changes on: trunk/source/extra/uconv/pkgdata.inc.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/resfiles.mk
===================================================================
--- trunk/source/extra/uconv/resfiles.mk	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/resfiles.mk	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,9 +1,9 @@
-# Copyright (c) 2000-2002 IBM, Inc. and Others.
-# A small makefile containing the list of resource bundles 
-# to include in uconv.
-
-# The variable FILESEPCHAR is defined by the caller to be
-# the character separating components of a filename.
-
-RESOURCESDIR = resources
-RESSRC = $(RESOURCESDIR)$(FILESEPCHAR)root.txt $(RESOURCESDIR)$(FILESEPCHAR)fr.txt
+# Copyright (c) 2000-2002 IBM, Inc. and Others.
+# A small makefile containing the list of resource bundles 
+# to include in uconv.
+
+# The variable FILESEPCHAR is defined by the caller to be
+# the character separating components of a filename.
+
+RESOURCESDIR = resources
+RESSRC = $(RESOURCESDIR)$(FILESEPCHAR)root.txt $(RESOURCESDIR)$(FILESEPCHAR)fr.txt


Property changes on: trunk/source/extra/uconv/resfiles.mk
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/resources/fr.txt
===================================================================
--- trunk/source/extra/uconv/resources/fr.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/resources/fr.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,103 +1,103 @@
-// -*- Coding: utf-8; -*-  [all uconv resource files]
-// Copyright (c) 2000-2004 IBM, Inc. and Others.
-//
-// Root translation file for uconv messages.
-// So you want to translate this file??? Great!
-// 1. copy it to a new name [ex: se.txt]
-//
-// 2. You might wish to comment out ALL lines, and then uncomment them
-//    as you add translations. That way, you don't inadvertently mark
-//    an untranslated English (or whatever) string as already
-//    translated. The base translation might change!
-// 
-// 3. These files are in UTF-8 format (even though root uses only
-//    ASCII)
-//
-// 4. Make note of the location of {0}, {1}, etc.. they are taken from
-//    arguments to u_wmsg() in order..
-//
-// 5. Add se.txt to RESSRC= in resfiles.mk and to the project file on 
-//    the Windows side.
-//
-// 6. Send it in to srl at jtcsv.com or ask on the ICU mailing list! thanks!
-
-fr
-{
-  // uconv errors
-
-    lcUsageWord { "usage" } 
-    ucUsageWord { "Usage" } 
-    usage {
-        "{0}: {1} "
-        "[ -h, -?, --help ] [ -V, --version ] [ -s, --silent ] [ -v, --verbose ] "
-        "[ -l, --list | --list-code code | --default-code | -L, --list-transliterators ] "
-        "[ --canon ] [ -x translitération ] "
-        "[ --to-callback callback | -c ] [ --from-callback callback | -i ] [ --callback callback ] "
-        "[ --fallback | --no-fallback ] "
-        "[ -b, --block-size taille ] "
-        "[ -f, --from-code code ] [ -t, --to-code code ] "
-        "[ --add-signature ] [ --remove-signature ] "
-        "[ -o, --output fichier ] "
-        "[ fichier ... ]\n"
-    }
-
-    // TODO there is some English in here
-    help { "Options :  -h, --help                   affiche ce message\n"
-           "           -V, --version                affiche la version du programme\n"
-"           -s, --silent                 supprime les messages\n"
-"           -v, --verbose                affiche les progrès\n"
-"           -l, --list                   liste tous les encodages disponibles\n"
-"           --list-code code             liste juste l''encodage donné\n"
-"           --default-code               liste juste l''encodage par défaut\n"
-"           -L, --list-transliterators   liste tous les translitérateurs\n"
-"           --canon                      affiche la liste dans le format de cnvrtrs.txt(5)\n"
-"           -x translitération           passe le texte à travers translitération\n"
-"           --to-callback callback       utilise callback sur l''encodage cible\n"
-"           -c                           omet les caractères invalides de la sortie\n"
-"           --from-callback callback     utilise callback sur l''encodage source\n"
-"           -i                           omet les séquences invalides de l''entrée\n"
-"           --callback callback          utilise callback sur les deux encodages\n"
-"           -b, --block-size taille      lit des blocks de taille octets (défaut : 4096)\n"
-"           --fallback                   utilise les correspondances de secours\n"
-"           --no-fallback                n''utilise pas les correspondances de secours\n"
-"           -f, --from-code code         fixe l''encodage d''origine\n"
-"           -t, --to-code code           fixe l''encodage de destination\n"
-"          --add-signature               add a U+FEFF Unicode signature character (BOM)\n"
-"          --remove-signature            remove a U+FEFF Unicode signature character (BOM)\n"
-"           -o, --output fichier         écrit la sortie dans fichier\n"
-"\n"
-"Callbacks :" } 
-
-    cantGetNames { "Ne peux obtenir la liste des encodages.\n" } // 0: err
-    cantGetTag { "Ne peux obtenir le nom de l'étiquette standard : {0}.\n" } // 0: err
-
-    noSuchCodeset { "Ne peux trouver l''encodage : {0}.\n" } // 0: name of the encoding
-    noFromCodeset { "L''encodage d''origine n''a pas été fixé (utilisez -f).\n" } 
-    noToCodeset { "L''encodage de destination n''a pas été fixé (utilisez -t).\n" } 
-
-    badBlockSize { "Taille de bloc incorrecte : {0}.\n" } // 0: size of the block
-
-    cantSetInBinMode { "Ne peux mettre l''entrée standard en mode binaire.\n" } 
-    cantSetOutBinMode { "Ne peux mettre la sortie standard en mode binaire.\n" } 
-
-    cantOpenFromCodeset { "Ne peux ouvrir de convertisseur pour l''encodage d''origine {0} : {1}.\n" } // 0:set, 1: err
-    cantOpenToCodeset { "Ne peux ouvrir de convertisseur pour l''encodage de destination {0} : {1}.\n" } // 0:set, 1: err
-
-    cantCreateTranslit { "Ne peux créer la translitération \"{0}\": {1}.\n" } // 0:set, 1: err
-    cantCreateTranslitParseErr { "Ne peux créer la translitération \"{0}\": {1}, ligne {2}, position {3}.\n" } // 0: set, 1: err, 2: line, 3: offset
-
-    cantSetCallback { "Ne peux fixer le callack de transcodage : {0}.\n" } // 0: err
-
-    unknownCallback { "Callback inconnu : {0}.\n" } // 0: callback name
-
-    cantOpenInputF { "Ne peux ouvrir le fichier d''entrée {0} : {1}.\n" } // 0: file, 1: strerror [OS error string] 
-    cantCreateOutputF { "Ne peux créer le fichier de sortie {0} : {1}.\n" } // 0: file, 1: strerror [OS error string]
-
-    cantWrite { "Le texte converti ne peut pas être écrit : {0}.\n" } // 0: OS error string
-    cantRead { "Erreur de lecture du fichier d''entrée : {0}.\n" } // 0: OS error string
-
-    // TODO retranslate the problemCvt... messages because their format changed
-    //problemCvtToU { "La conversion d''Unicode vers l''encodage de destination a échoué à la position {0} : {1}.\n" } // 0: position, 1: err
-    //problemCvtFromU { "La conversion de l''encodage original vers Unicode a échoué à la position {0} : {1}.\n" } // 0: position, 1: err
-    //problemCvtFromUOut { "La conversion de l''encodage original vers Unicode a échoué à la position {0} de la sortie : {1}.\n" } // 0: position, 1: err
-}
+// -*- Coding: utf-8; -*-  [all uconv resource files]
+// Copyright (c) 2000-2004 IBM, Inc. and Others.
+//
+// Root translation file for uconv messages.
+// So you want to translate this file??? Great!
+// 1. copy it to a new name [ex: se.txt]
+//
+// 2. You might wish to comment out ALL lines, and then uncomment them
+//    as you add translations. That way, you don't inadvertently mark
+//    an untranslated English (or whatever) string as already
+//    translated. The base translation might change!
+// 
+// 3. These files are in UTF-8 format (even though root uses only
+//    ASCII)
+//
+// 4. Make note of the location of {0}, {1}, etc.. they are taken from
+//    arguments to u_wmsg() in order..
+//
+// 5. Add se.txt to RESSRC= in resfiles.mk and to the project file on 
+//    the Windows side.
+//
+// 6. Send it in to srl at jtcsv.com or ask on the ICU mailing list! thanks!
+
+fr
+{
+  // uconv errors
+
+    lcUsageWord { "usage" } 
+    ucUsageWord { "Usage" } 
+    usage {
+        "{0}: {1} "
+        "[ -h, -?, --help ] [ -V, --version ] [ -s, --silent ] [ -v, --verbose ] "
+        "[ -l, --list | --list-code code | --default-code | -L, --list-transliterators ] "
+        "[ --canon ] [ -x translitération ] "
+        "[ --to-callback callback | -c ] [ --from-callback callback | -i ] [ --callback callback ] "
+        "[ --fallback | --no-fallback ] "
+        "[ -b, --block-size taille ] "
+        "[ -f, --from-code code ] [ -t, --to-code code ] "
+        "[ --add-signature ] [ --remove-signature ] "
+        "[ -o, --output fichier ] "
+        "[ fichier ... ]\n"
+    }
+
+    // TODO there is some English in here
+    help { "Options :  -h, --help                   affiche ce message\n"
+           "           -V, --version                affiche la version du programme\n"
+"           -s, --silent                 supprime les messages\n"
+"           -v, --verbose                affiche les progrès\n"
+"           -l, --list                   liste tous les encodages disponibles\n"
+"           --list-code code             liste juste l''encodage donné\n"
+"           --default-code               liste juste l''encodage par défaut\n"
+"           -L, --list-transliterators   liste tous les translitérateurs\n"
+"           --canon                      affiche la liste dans le format de cnvrtrs.txt(5)\n"
+"           -x translitération           passe le texte à travers translitération\n"
+"           --to-callback callback       utilise callback sur l''encodage cible\n"
+"           -c                           omet les caractères invalides de la sortie\n"
+"           --from-callback callback     utilise callback sur l''encodage source\n"
+"           -i                           omet les séquences invalides de l''entrée\n"
+"           --callback callback          utilise callback sur les deux encodages\n"
+"           -b, --block-size taille      lit des blocks de taille octets (défaut : 4096)\n"
+"           --fallback                   utilise les correspondances de secours\n"
+"           --no-fallback                n''utilise pas les correspondances de secours\n"
+"           -f, --from-code code         fixe l''encodage d''origine\n"
+"           -t, --to-code code           fixe l''encodage de destination\n"
+"          --add-signature               add a U+FEFF Unicode signature character (BOM)\n"
+"          --remove-signature            remove a U+FEFF Unicode signature character (BOM)\n"
+"           -o, --output fichier         écrit la sortie dans fichier\n"
+"\n"
+"Callbacks :" } 
+
+    cantGetNames { "Ne peux obtenir la liste des encodages.\n" } // 0: err
+    cantGetTag { "Ne peux obtenir le nom de l'étiquette standard : {0}.\n" } // 0: err
+
+    noSuchCodeset { "Ne peux trouver l''encodage : {0}.\n" } // 0: name of the encoding
+    noFromCodeset { "L''encodage d''origine n''a pas été fixé (utilisez -f).\n" } 
+    noToCodeset { "L''encodage de destination n''a pas été fixé (utilisez -t).\n" } 
+
+    badBlockSize { "Taille de bloc incorrecte : {0}.\n" } // 0: size of the block
+
+    cantSetInBinMode { "Ne peux mettre l''entrée standard en mode binaire.\n" } 
+    cantSetOutBinMode { "Ne peux mettre la sortie standard en mode binaire.\n" } 
+
+    cantOpenFromCodeset { "Ne peux ouvrir de convertisseur pour l''encodage d''origine {0} : {1}.\n" } // 0:set, 1: err
+    cantOpenToCodeset { "Ne peux ouvrir de convertisseur pour l''encodage de destination {0} : {1}.\n" } // 0:set, 1: err
+
+    cantCreateTranslit { "Ne peux créer la translitération \"{0}\": {1}.\n" } // 0:set, 1: err
+    cantCreateTranslitParseErr { "Ne peux créer la translitération \"{0}\": {1}, ligne {2}, position {3}.\n" } // 0: set, 1: err, 2: line, 3: offset
+
+    cantSetCallback { "Ne peux fixer le callack de transcodage : {0}.\n" } // 0: err
+
+    unknownCallback { "Callback inconnu : {0}.\n" } // 0: callback name
+
+    cantOpenInputF { "Ne peux ouvrir le fichier d''entrée {0} : {1}.\n" } // 0: file, 1: strerror [OS error string] 
+    cantCreateOutputF { "Ne peux créer le fichier de sortie {0} : {1}.\n" } // 0: file, 1: strerror [OS error string]
+
+    cantWrite { "Le texte converti ne peut pas être écrit : {0}.\n" } // 0: OS error string
+    cantRead { "Erreur de lecture du fichier d''entrée : {0}.\n" } // 0: OS error string
+
+    // TODO retranslate the problemCvt... messages because their format changed
+    //problemCvtToU { "La conversion d''Unicode vers l''encodage de destination a échoué à la position {0} : {1}.\n" } // 0: position, 1: err
+    //problemCvtFromU { "La conversion de l''encodage original vers Unicode a échoué à la position {0} : {1}.\n" } // 0: position, 1: err
+    //problemCvtFromUOut { "La conversion de l''encodage original vers Unicode a échoué à la position {0} de la sortie : {1}.\n" } // 0: position, 1: err
+}


Property changes on: trunk/source/extra/uconv/resources/fr.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/resources/root.txt
===================================================================
--- trunk/source/extra/uconv/resources/root.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/resources/root.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,127 +1,127 @@
-// -*- Coding: utf-8; -*-  [all uconv resource files]
-// Copyright (c) 2000-2004 IBM, Inc. and Others.
-//
-// Root translation file for uconv messages.
-// So you want to translate this file??? Great!
-// 1. copy it to a new name [ex: se.txt]
-//
-// 2. You might wish to comment out ALL lines, and then uncomment them
-//    as you add translations. That way, you don't inadvertently mark
-//    an untranslated English (or whatever) string as already
-//    translated. The base translation might change!
-// 
-// 3. These files are in UTF-8 format (even though root uses only
-//    ASCII)
-//
-// 4. Make note of the location of {0}, {1}, etc.. they are taken from
-//    arguments to u_wmsg() in order..
-//
-// 5. Add se.txt to RESSRC= in resfiles.mk and to the project file on 
-//    the Windows side.
-//
-// 6. Send it in to srl at jtcsv.com or ask on the ICU mailing list! thanks!
-
-root
-{
-  // uconv errors
-
-  lcUsageWord { "usage" }
-  ucUsageWord { "Usage" }
-  usage {
-    "{0}: {1} "
-    "[ -h, -?, --help ] [ -V, --version ] [ -s, --silent ] [ -v, --verbose ] "
-    "[ -l, --list | --list-code code | --default-code | -L, --list-transliterators ] "
-    "[ --canon ] [ -x transliteration ] "
-    "[ --to-callback callback | -c ] [ --from-callback callback | -i ] [ --callback callback ] "
-    "[ --fallback | --no-fallback ] "
-    "[ -b, --block-size size ] "
-    "[ -f, --from-code code ] [ -t, --to-code code ] "
-    "[ --add-signature ] [ --remove-signature ] "
-    "[ -o, --output file ] "
-    "[ file ... ]\n" }
-
-  help {  "Options:  -h, --help                    print this message\n"
-          "          -V, --version                 print the program version\n"
-          "          -s, --silent                  suppress messages\n"
-          "          -v, --verbose                 display progress information\n"
-          "          -l, --list                    list all available encodings\n"
-          "          --list-code code              list only the given encoding\n"
-          "          --default-code                list only the default encoding\n"
-          "          -L, --list-transliterators    list all available transliterators\n"
-          "          --canon                       print list in cnvrtrs.txt(5) format\n"
-          "          -x transliteration            run everything through transliteration\n" 
-          "          --to-callback callback        use callback on destination encoding\n"
-          "          -c                            omit invalid characters from the output\n"
-          "          --from-callback callback      use callback on original encoding\n"
-          "          -i                            ignore invalid sequences in the input\n"
-          "          --callback callback           use callback on both encodings\n"
-          "          -b, --block-size size         read size bytes blocks (default: 4096)\n"
-          "          --fallback                    use fallback mapping\n"
-          "          --no-fallback                 do not use fallback mapping\n"
-          "          -f, --from-code code          set the original encoding\n"
-          "          -t, --to-code code            set the destination encoding\n" 
-          "          --add-signature               add a U+FEFF Unicode signature character (BOM)\n"
-          "          --remove-signature            remove a U+FEFF Unicode signature character (BOM)\n"
-          "          -o, --output file             write output to file\n"
-          "\n"
-          "Callbacks:"
-  }
-
-  cantGetNames   { "Couldn''t get available converter names.\n" } // 0: err
-  cantGetTag   { "Couldn''t get standard tag name: {0}.\n" } // 0: err
-  
-  noSuchCodeset  { "Couldn''t find encoding: {0}.\n" } // 0: name of the encoding
-  noFromCodeset  { "No original encoding set (use -f).\n" }
-  noToCodeset    {  "No destination encoding set (use -t).\n" }
-
-  badBlockSize  { "Bad block size: {0}.\n" } // 0: size of the block
-
-  cantSetInBinMode { "Couldn't set standard input to binary mode." }
-  cantSetOutBinMode { "Couldn't set standard output to binary mode." }
-
-  cantOpenFromCodeset { "Couldn''t open converter for original encoding {0}: {1}.\n" } // 0:set, 1: err
-  cantOpenToCodeset { "Couldn''t open converteur for destination encoding {0}: {1}.\n" } // 0: set, 1: err
-
-  cantCreateTranslit { "Couldn''t create transliteration \"{0}\": {1}.\n" } // 0: set, 1: err
-  cantCreateTranslitParseErr { "Couldn''t create transliteration \"{0}\": {1}, line {2}, offset {3}.\n" } // 0: set, 1: err, 2: line, 3: offset
-
-  cantSetCallback { "Couldn''t set transcoding callback: {0}.\n" } // 0: err
-
-  unknownCallback { "Unknown callback: {0}.\n" } // 0: callback name
-
-  cantOpenInputF  { "Couldn''t open input file {0}: {1}.\n" } // 0: file, 1: strerror [OS error string]
-  cantCreateOutputF  { "Couldn''t create output file {0}: {1}.\n" } // 0: file, 1: strerror [OS error string]
-
-  cantWrite       { "The converted text couldn't be written: {0}.\n" } // 0: OS error string
-  cantRead        { "Error reading from input file: {0}.\n" } // 0: OS error string
-
-  problemCvtToU   { "Conversion to Unicode from codepage failed at input byte position {0}. Bytes: {1} Error: {2}\n" } // 0: position, 1: bytes, 2: err
-  problemCvtFromU { "Conversion from Unicode to codepage failed at input byte position {0}. Unicode: {1} Error: {2}\n"} // 0: position, 1: Unicode, 2: err
-  problemCvtFromUOut { "Conversion from Unicode to codepage failed at output byte position {0}. Unicode: {1} Error: {2}\n"} // 0: position, 1: Unicode, 2: err
-
-// ICU errors - used by u_wmsg_errorName()
-
-  U_USING_FALLBACK_ERROR       { "Using fallback data" }
-  U_USING_DEFAULT_ERROR        { "Using default data" }
-  U_ZERO_ERROR                 { "No error has occured" }
-  U_ILLEGAL_ARGUMENT_ERROR     { "Illegal argument" }
-  U_MISSING_RESOURCE_ERROR     { "A resource was missing" }
-  U_INVALID_FORMAT_ERROR       { "Invalid format" }
-  U_FILE_ACCESS_ERROR          { "Problem accessing that file/object" }
-  U_INTERNAL_PROGRAM_ERROR     { "Internal program error" }
-  U_MESSAGE_PARSE_ERROR        { "Parse error on message format" }
-  U_MEMORY_ALLOCATION_ERROR    { "Out of memory" }
-  U_INDEX_OUTOFBOUNDS_ERROR    { "An index was out-of-bounds" }
-  U_PARSE_ERROR                { "Parse error" }
-  U_INVALID_CHAR_FOUND         { "Invalid character found" }
-  U_TRUNCATED_CHAR_FOUND       { "Truncated character found" }
-  U_ILLEGAL_CHAR_FOUND         { "Illegal character found" }
-  U_INVALID_TABLE_FORMAT       { "Invalid table data format" }
-  U_INVALID_TABLE_FILE         { "Invalid table data file" }
-  U_BUFFER_OVERFLOW_ERROR      { "Buffer overflow" }
-  U_UNSUPPORTED_ERROR          { "A feature was unsupported" }
-  U_RESOURCE_TYPE_MISMATCH     { "Resource type mismatch" }
-  U_ILLEGAL_ESCAPE_SEQUENCE    { "Illegal escape sequence found" }
-  U_UNSUPPORTED_ESCAPE_SEQUENCE {"Unsupported escape sequence found" }
-}
-
+// -*- Coding: utf-8; -*-  [all uconv resource files]
+// Copyright (c) 2000-2004 IBM, Inc. and Others.
+//
+// Root translation file for uconv messages.
+// So you want to translate this file??? Great!
+// 1. copy it to a new name [ex: se.txt]
+//
+// 2. You might wish to comment out ALL lines, and then uncomment them
+//    as you add translations. That way, you don't inadvertently mark
+//    an untranslated English (or whatever) string as already
+//    translated. The base translation might change!
+// 
+// 3. These files are in UTF-8 format (even though root uses only
+//    ASCII)
+//
+// 4. Make note of the location of {0}, {1}, etc.. they are taken from
+//    arguments to u_wmsg() in order..
+//
+// 5. Add se.txt to RESSRC= in resfiles.mk and to the project file on 
+//    the Windows side.
+//
+// 6. Send it in to srl at jtcsv.com or ask on the ICU mailing list! thanks!
+
+root
+{
+  // uconv errors
+
+  lcUsageWord { "usage" }
+  ucUsageWord { "Usage" }
+  usage {
+    "{0}: {1} "
+    "[ -h, -?, --help ] [ -V, --version ] [ -s, --silent ] [ -v, --verbose ] "
+    "[ -l, --list | --list-code code | --default-code | -L, --list-transliterators ] "
+    "[ --canon ] [ -x transliteration ] "
+    "[ --to-callback callback | -c ] [ --from-callback callback | -i ] [ --callback callback ] "
+    "[ --fallback | --no-fallback ] "
+    "[ -b, --block-size size ] "
+    "[ -f, --from-code code ] [ -t, --to-code code ] "
+    "[ --add-signature ] [ --remove-signature ] "
+    "[ -o, --output file ] "
+    "[ file ... ]\n" }
+
+  help {  "Options:  -h, --help                    print this message\n"
+          "          -V, --version                 print the program version\n"
+          "          -s, --silent                  suppress messages\n"
+          "          -v, --verbose                 display progress information\n"
+          "          -l, --list                    list all available encodings\n"
+          "          --list-code code              list only the given encoding\n"
+          "          --default-code                list only the default encoding\n"
+          "          -L, --list-transliterators    list all available transliterators\n"
+          "          --canon                       print list in cnvrtrs.txt(5) format\n"
+          "          -x transliteration            run everything through transliteration\n" 
+          "          --to-callback callback        use callback on destination encoding\n"
+          "          -c                            omit invalid characters from the output\n"
+          "          --from-callback callback      use callback on original encoding\n"
+          "          -i                            ignore invalid sequences in the input\n"
+          "          --callback callback           use callback on both encodings\n"
+          "          -b, --block-size size         read size bytes blocks (default: 4096)\n"
+          "          --fallback                    use fallback mapping\n"
+          "          --no-fallback                 do not use fallback mapping\n"
+          "          -f, --from-code code          set the original encoding\n"
+          "          -t, --to-code code            set the destination encoding\n" 
+          "          --add-signature               add a U+FEFF Unicode signature character (BOM)\n"
+          "          --remove-signature            remove a U+FEFF Unicode signature character (BOM)\n"
+          "          -o, --output file             write output to file\n"
+          "\n"
+          "Callbacks:"
+  }
+
+  cantGetNames   { "Couldn''t get available converter names.\n" } // 0: err
+  cantGetTag   { "Couldn''t get standard tag name: {0}.\n" } // 0: err
+  
+  noSuchCodeset  { "Couldn''t find encoding: {0}.\n" } // 0: name of the encoding
+  noFromCodeset  { "No original encoding set (use -f).\n" }
+  noToCodeset    {  "No destination encoding set (use -t).\n" }
+
+  badBlockSize  { "Bad block size: {0}.\n" } // 0: size of the block
+
+  cantSetInBinMode { "Couldn't set standard input to binary mode." }
+  cantSetOutBinMode { "Couldn't set standard output to binary mode." }
+
+  cantOpenFromCodeset { "Couldn''t open converter for original encoding {0}: {1}.\n" } // 0:set, 1: err
+  cantOpenToCodeset { "Couldn''t open converteur for destination encoding {0}: {1}.\n" } // 0: set, 1: err
+
+  cantCreateTranslit { "Couldn''t create transliteration \"{0}\": {1}.\n" } // 0: set, 1: err
+  cantCreateTranslitParseErr { "Couldn''t create transliteration \"{0}\": {1}, line {2}, offset {3}.\n" } // 0: set, 1: err, 2: line, 3: offset
+
+  cantSetCallback { "Couldn''t set transcoding callback: {0}.\n" } // 0: err
+
+  unknownCallback { "Unknown callback: {0}.\n" } // 0: callback name
+
+  cantOpenInputF  { "Couldn''t open input file {0}: {1}.\n" } // 0: file, 1: strerror [OS error string]
+  cantCreateOutputF  { "Couldn''t create output file {0}: {1}.\n" } // 0: file, 1: strerror [OS error string]
+
+  cantWrite       { "The converted text couldn't be written: {0}.\n" } // 0: OS error string
+  cantRead        { "Error reading from input file: {0}.\n" } // 0: OS error string
+
+  problemCvtToU   { "Conversion to Unicode from codepage failed at input byte position {0}. Bytes: {1} Error: {2}\n" } // 0: position, 1: bytes, 2: err
+  problemCvtFromU { "Conversion from Unicode to codepage failed at input byte position {0}. Unicode: {1} Error: {2}\n"} // 0: position, 1: Unicode, 2: err
+  problemCvtFromUOut { "Conversion from Unicode to codepage failed at output byte position {0}. Unicode: {1} Error: {2}\n"} // 0: position, 1: Unicode, 2: err
+
+// ICU errors - used by u_wmsg_errorName()
+
+  U_USING_FALLBACK_ERROR       { "Using fallback data" }
+  U_USING_DEFAULT_ERROR        { "Using default data" }
+  U_ZERO_ERROR                 { "No error has occured" }
+  U_ILLEGAL_ARGUMENT_ERROR     { "Illegal argument" }
+  U_MISSING_RESOURCE_ERROR     { "A resource was missing" }
+  U_INVALID_FORMAT_ERROR       { "Invalid format" }
+  U_FILE_ACCESS_ERROR          { "Problem accessing that file/object" }
+  U_INTERNAL_PROGRAM_ERROR     { "Internal program error" }
+  U_MESSAGE_PARSE_ERROR        { "Parse error on message format" }
+  U_MEMORY_ALLOCATION_ERROR    { "Out of memory" }
+  U_INDEX_OUTOFBOUNDS_ERROR    { "An index was out-of-bounds" }
+  U_PARSE_ERROR                { "Parse error" }
+  U_INVALID_CHAR_FOUND         { "Invalid character found" }
+  U_TRUNCATED_CHAR_FOUND       { "Truncated character found" }
+  U_ILLEGAL_CHAR_FOUND         { "Illegal character found" }
+  U_INVALID_TABLE_FORMAT       { "Invalid table data format" }
+  U_INVALID_TABLE_FILE         { "Invalid table data file" }
+  U_BUFFER_OVERFLOW_ERROR      { "Buffer overflow" }
+  U_UNSUPPORTED_ERROR          { "A feature was unsupported" }
+  U_RESOURCE_TYPE_MISMATCH     { "Resource type mismatch" }
+  U_ILLEGAL_ESCAPE_SEQUENCE    { "Illegal escape sequence found" }
+  U_UNSUPPORTED_ESCAPE_SEQUENCE {"Unsupported escape sequence found" }
+}
+


Property changes on: trunk/source/extra/uconv/resources/root.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/ISO-8859-2.txt
===================================================================
--- trunk/source/extra/uconv/samples/ISO-8859-2.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/ISO-8859-2.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-Dobar dan! Kako ste? Ja sam Marina
-Dodigoviæ. Kako se Vi zovete?
+Dobar dan! Kako ste? Ja sam Marina
+Dodigoviæ. Kako se Vi zovete?


Property changes on: trunk/source/extra/uconv/samples/ISO-8859-2.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/ISO-8859-3.txt
===================================================================
--- trunk/source/extra/uconv/samples/ISO-8859-3.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/ISO-8859-3.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,6 +1,6 @@
-Yukarda mavi gök, asa»¹da ya»¹z yer yarat¹ld¹kta; ikisinin aras¹nda insan
-o»lu yarat¹lm¹º. ©nsan o»ullar¹ üzerine ecdad¹m Bum¹n hakan, ©stemi hakan
-tahta oturmuº; oturarak Türk milletinin ülkesini, türesini, idare edivermiº,
-tanzim edivermis. Dört taraf hep düºman imiº. Asker sevk edip dört taraftaki
-kavmi hep (itaati alt¹na) alm¹º hep muti k¹lm¹º. Baºl¹lara baº e»dirmiº,
-dizlilere diz çöktürmüº.
+Yukarda mavi gök, asa»¹da ya»¹z yer yarat¹ld¹kta; ikisinin aras¹nda insan
+o»lu yarat¹lm¹º. ©nsan o»ullar¹ üzerine ecdad¹m Bum¹n hakan, ©stemi hakan
+tahta oturmuº; oturarak Türk milletinin ülkesini, türesini, idare edivermiº,
+tanzim edivermis. Dört taraf hep düºman imiº. Asker sevk edip dört taraftaki
+kavmi hep (itaati alt¹na) alm¹º hep muti k¹lm¹º. Baºl¹lara baº e»dirmiº,
+dizlilere diz çöktürmüº.


Property changes on: trunk/source/extra/uconv/samples/ISO-8859-3.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/danish-ISO-8859-1.txt
===================================================================
--- trunk/source/extra/uconv/samples/danish-ISO-8859-1.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/danish-ISO-8859-1.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,18 +1,18 @@
- Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
- (H. C. Andersens Hus, Odense).
-
-BARNDOMSOMGIVELSERNE</b>
- Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
- solbeskinnede.
-    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
- og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
- beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
- får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
- immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
- avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
- almissemedlemmer, 29 pensionister og rentenydere.
-    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
- når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
- idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
- længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
- forværredes sygdommen og han døde.
+ Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
+ (H. C. Andersens Hus, Odense).
+
+BARNDOMSOMGIVELSERNE</b>
+ Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
+ solbeskinnede.
+    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
+ og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
+ beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
+ får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
+ immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
+ avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
+ almissemedlemmer, 29 pensionister og rentenydere.
+    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
+ når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
+ idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
+ længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
+ forværredes sygdommen og han døde.


Property changes on: trunk/source/extra/uconv/samples/danish-ISO-8859-1.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/eucJP.txt
===================================================================
--- trunk/source/extra/uconv/samples/eucJP.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/eucJP.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,37 +1,37 @@
-¥¦¥¤¥ó¥«¥ê¥Ã¥¹¤ÎÆüËܸì
-¡¡  ¡Ö¥æ¡¼¥¶¡¼¥Õ¥ì¥ó¥É¥ê¡×¡Ã¤È¡Ã¸Æ¤Ð¤ì¤ë¡Ã
-¡¡¡¡¤ê¤æ¤¦¤Ï¡¢¤´¤¯ ¡ÃÉáÄ̤Ρÿͤ¬¤´¤¯¡Ã
-¡¡¡¡´Øñ¤Ë  ¡Ã»ÈÍÑ ¡ÃÊýË¡¤ò¡Ã¥Þ¥¹¥¿¡¼¡Ã¤Ç¤­¡¢¡Ã
-¡¡¡¡ËèÆü¤Î¡Ã¥¿¥¤¥× ¡Ã ¤Î ¡Ã»Å»ö¤Ë¤¹¤°  ¡Ã 
-¡¡¡¡ÌòΩ¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£¡Ã
-¡¡¡¡¤è¤Ð¤ì¤ë¡¡¡¡¡¡¡¡?¡¡¡¡¡¡ ¡¡¸Æ¤Ð¤ì¤ë
-¡¡¡¡¤ê¤å¤¦¤Ï¡¢¤´¤¯¡¡?¡¡¡¡¡¡¡¡ Íýͳ¤Ï¡¢¤´¤¯
-¡¡¡¡¤Õ¤Ä¤¦¤Î¡¡¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ÉáÄ̤Î
-¡¡¡¡¤Ò¤È¤¬¤´¤¯¡¡¡¡¡¡?¡¡¡¡¡¡¡¡¿Í¤¬¤´¤¯
-¡¡¡¡¤«¤ó¤¿¤ó¤Ë¡¡¡¡¡¡?¡¡¡¡¡¡¡¡´Êñ¤Ë
-¡¡¡¡¤·¤è¤¦¡¡¡¡¡¡¡¡¡¡?¡¡¡¡¡¡¡¡»ÈÍÑ
-¡¡¡¡¤Û¤¦¤Û¤¦¤ò¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ÊýË¡¤ò
-¡¡¡¡¤Þ¤¤¤Ë¤Á¤Î¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ËèÆü¤Î
-¡¡¡¡¤·¤´¤È¤Ë¤¹¤°¡¡¡¡?¡¡¡¡¡¡¡¡»Å»ö¤Ë¤¹¤°
-¡¡¡¡¤ä¤¯¤À¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£?
-¡¡¡¡ÌòΩ¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£
-¤¢¡¡¤¤¡¡¤¦¡¡¤¨¡¡¤ª¡¡
-¤¡¡¡¤£¡¡¤¥¡¡¤§¡¡¤©
-¤«¡¡¤­¡¡¤¯¡¡¤±¡¡¤³¡¡¡¡¤­¤ã      ¤­¤å¡¡¤­¤ç
-¤µ¡¡¤·¡¡¤¹¡¡¤»¡¡¤½¡¡¡¡¤·¤ã¡¡  ¤·¤å     ¤·¤§¡¡¤·¤ç
-¤¿¡¡¤Á¡¡¤Ä¡¡¤Æ¡¡¤È¡¡¡¡ ¤Á¤ã¡¡¤Á¤å¡¡¤Á¤§  ¤Á¤ç
-¤Ê¡¡¤Ë¡¡¤Ì¡¡¤Í¡¡¤Î¡¡¡¡  ¤Ë¤ã¡¡  ¤Ë¤å¡¡¤Ë¤ç
-¤Ï¡¡¤Ò¡¡¤Õ¡¡¤Ø¡¡¤Û¡¡¡¡   ¤Ò¤ã   ¡¡¤Ò¤å    ¤Ò¤ç
-                                                        ¤Õ¤¡¡¡¤Õ¤£¡¡¤Õ¤§¡¡¤Õ¤©
-¤Þ¡¡¤ß¡¡¤à¡¡¤á¡¡¤â¡¡¡¡   ¤ß¤ã¡¡¡¡¤ß¤å¡¡¡¡¤ß¤ç
-¤ä¡¡(¤¤)¡¡¤æ   (¤¨)   ¤è¡¡¡¡ ¤ã¡¡¡¡¡¡¤å¡¡¡¡¡¡¤ç
-¤é¡¡¤ê¡¡¤ë¡¡¤ì¡¡¤í¡¡¡¡¤ê¤ã      ¤ê¤å¡¡      ¤ê¤ç
-¤ï¡¡¤ð    (¤¦)   ¤ñ¡¡ ¤ò          ¤î           ¡¡¥ð¡¡¡¡¡¡¥ñ
-¤ó               ?               ¤Ã            ¥«¡¡¥±
-¤¬¡¡¤®¡¡¤°¡¡¤²¡¡¤´¡¡¡¡  ¤®¤ã¡¡¤®¤å¡¡¤®¤ç
-                                                        ¤°¤î¡¡¤°¤§
-¤¶¡¡¤¸¡¡¤º¡¡¤¼¡¡¤¾¡¡¡¡¤¸¤ã¡¡   ¤¸¤å¡¡ ¤¸¤§¡¡¤¸¤ç
-¤À¡¡¤Â¡¡¤Å¡¡¤Ç¡¡¤É¡¡¡¡¤Â¤ã¡¡¤Â¤£¡¡   ¤Â¤å     ¤Â¤§¡¡¤Â¤©
-¤Ð¡¡¤Ó¡¡¤Ö¡¡¤Ù¡¡¤Ü¡¡¡¡¡¡¤Ó¤ã¡¡¤Ó¤å¡¡¤Ó¤ç
-¤Ñ¡¡¤Ô¡¡¤×¡¡¤Ú¡¡¤Ý¡¡¡¡¡¡¤Ô¤ã¡¡¤Ô¤å¡¡¤Ô¤ç
-¥ï¡¡¥¦¥£  ¥¦¡¡¥¦¥§  ¥¦¥©¡¡¥ô¥¡¡¡¥ô¥£¡¡¥ô¡¡¥ô¥§¡¡¥ô¥©
+¥¦¥¤¥ó¥«¥ê¥Ã¥¹¤ÎÆüËܸì
+¡¡  ¡Ö¥æ¡¼¥¶¡¼¥Õ¥ì¥ó¥É¥ê¡×¡Ã¤È¡Ã¸Æ¤Ð¤ì¤ë¡Ã
+¡¡¡¡¤ê¤æ¤¦¤Ï¡¢¤´¤¯ ¡ÃÉáÄ̤Ρÿͤ¬¤´¤¯¡Ã
+¡¡¡¡´Øñ¤Ë  ¡Ã»ÈÍÑ ¡ÃÊýË¡¤ò¡Ã¥Þ¥¹¥¿¡¼¡Ã¤Ç¤­¡¢¡Ã
+¡¡¡¡ËèÆü¤Î¡Ã¥¿¥¤¥× ¡Ã ¤Î ¡Ã»Å»ö¤Ë¤¹¤°  ¡Ã 
+¡¡¡¡ÌòΩ¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£¡Ã
+¡¡¡¡¤è¤Ð¤ì¤ë¡¡¡¡¡¡¡¡?¡¡¡¡¡¡ ¡¡¸Æ¤Ð¤ì¤ë
+¡¡¡¡¤ê¤å¤¦¤Ï¡¢¤´¤¯¡¡?¡¡¡¡¡¡¡¡ Íýͳ¤Ï¡¢¤´¤¯
+¡¡¡¡¤Õ¤Ä¤¦¤Î¡¡¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ÉáÄ̤Î
+¡¡¡¡¤Ò¤È¤¬¤´¤¯¡¡¡¡¡¡?¡¡¡¡¡¡¡¡¿Í¤¬¤´¤¯
+¡¡¡¡¤«¤ó¤¿¤ó¤Ë¡¡¡¡¡¡?¡¡¡¡¡¡¡¡´Êñ¤Ë
+¡¡¡¡¤·¤è¤¦¡¡¡¡¡¡¡¡¡¡?¡¡¡¡¡¡¡¡»ÈÍÑ
+¡¡¡¡¤Û¤¦¤Û¤¦¤ò¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ÊýË¡¤ò
+¡¡¡¡¤Þ¤¤¤Ë¤Á¤Î¡¡¡¡¡¡?¡¡¡¡¡¡¡¡ËèÆü¤Î
+¡¡¡¡¤·¤´¤È¤Ë¤¹¤°¡¡¡¡?¡¡¡¡¡¡¡¡»Å»ö¤Ë¤¹¤°
+¡¡¡¡¤ä¤¯¤À¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£?
+¡¡¡¡ÌòΩ¤Æ¤ë¤³¤È¤¬¤Ç¤­¤ë¤³¤È¤«¤é¤­¤Æ¤¤¤ë¡£
+¤¢¡¡¤¤¡¡¤¦¡¡¤¨¡¡¤ª¡¡
+¤¡¡¡¤£¡¡¤¥¡¡¤§¡¡¤©
+¤«¡¡¤­¡¡¤¯¡¡¤±¡¡¤³¡¡¡¡¤­¤ã      ¤­¤å¡¡¤­¤ç
+¤µ¡¡¤·¡¡¤¹¡¡¤»¡¡¤½¡¡¡¡¤·¤ã¡¡  ¤·¤å     ¤·¤§¡¡¤·¤ç
+¤¿¡¡¤Á¡¡¤Ä¡¡¤Æ¡¡¤È¡¡¡¡ ¤Á¤ã¡¡¤Á¤å¡¡¤Á¤§  ¤Á¤ç
+¤Ê¡¡¤Ë¡¡¤Ì¡¡¤Í¡¡¤Î¡¡¡¡  ¤Ë¤ã¡¡  ¤Ë¤å¡¡¤Ë¤ç
+¤Ï¡¡¤Ò¡¡¤Õ¡¡¤Ø¡¡¤Û¡¡¡¡   ¤Ò¤ã   ¡¡¤Ò¤å    ¤Ò¤ç
+                                                        ¤Õ¤¡¡¡¤Õ¤£¡¡¤Õ¤§¡¡¤Õ¤©
+¤Þ¡¡¤ß¡¡¤à¡¡¤á¡¡¤â¡¡¡¡   ¤ß¤ã¡¡¡¡¤ß¤å¡¡¡¡¤ß¤ç
+¤ä¡¡(¤¤)¡¡¤æ   (¤¨)   ¤è¡¡¡¡ ¤ã¡¡¡¡¡¡¤å¡¡¡¡¡¡¤ç
+¤é¡¡¤ê¡¡¤ë¡¡¤ì¡¡¤í¡¡¡¡¤ê¤ã      ¤ê¤å¡¡      ¤ê¤ç
+¤ï¡¡¤ð    (¤¦)   ¤ñ¡¡ ¤ò          ¤î           ¡¡¥ð¡¡¡¡¡¡¥ñ
+¤ó               ?               ¤Ã            ¥«¡¡¥±
+¤¬¡¡¤®¡¡¤°¡¡¤²¡¡¤´¡¡¡¡  ¤®¤ã¡¡¤®¤å¡¡¤®¤ç
+                                                        ¤°¤î¡¡¤°¤§
+¤¶¡¡¤¸¡¡¤º¡¡¤¼¡¡¤¾¡¡¡¡¤¸¤ã¡¡   ¤¸¤å¡¡ ¤¸¤§¡¡¤¸¤ç
+¤À¡¡¤Â¡¡¤Å¡¡¤Ç¡¡¤É¡¡¡¡¤Â¤ã¡¡¤Â¤£¡¡   ¤Â¤å     ¤Â¤§¡¡¤Â¤©
+¤Ð¡¡¤Ó¡¡¤Ö¡¡¤Ù¡¡¤Ü¡¡¡¡¡¡¤Ó¤ã¡¡¤Ó¤å¡¡¤Ó¤ç
+¤Ñ¡¡¤Ô¡¡¤×¡¡¤Ú¡¡¤Ý¡¡¡¡¡¡¤Ô¤ã¡¡¤Ô¤å¡¡¤Ô¤ç
+¥ï¡¡¥¦¥£  ¥¦¡¡¥¦¥§  ¥¦¥©¡¡¥ô¥¡¡¡¥ô¥£¡¡¥ô¡¡¥ô¥§¡¡¥ô¥©


Property changes on: trunk/source/extra/uconv/samples/eucJP.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/hangul-eucKR.txt
===================================================================
--- trunk/source/extra/uconv/samples/hangul-eucKR.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/hangul-eucKR.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-µµ¼­°ü
-Çѱ¹
+µµ¼­°ü
+Çѱ¹


Property changes on: trunk/source/extra/uconv/samples/hangul-eucKR.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/hania-eucKR.txt
===================================================================
--- trunk/source/extra/uconv/samples/hania-eucKR.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/hania-eucKR.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-??º§ 
+??º§ 
 ??
\ No newline at end of file


Property changes on: trunk/source/extra/uconv/samples/hania-eucKR.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/iso8859-1.txt
===================================================================
--- trunk/source/extra/uconv/samples/iso8859-1.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/iso8859-1.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,18 +1,18 @@
- Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
- (H. C. Andersens Hus, Odense).
-
-BARNDOMSOMGIVELSERNE</b>
- Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
- solbeskinnede.
-    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
- og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
- beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
- får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
- immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
- avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
- almissemedlemmer, 29 pensionister og rentenydere.
-    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
- når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
- idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
- længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
- forværredes sygdommen og han døde.
+ Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
+ (H. C. Andersens Hus, Odense).
+
+BARNDOMSOMGIVELSERNE</b>
+ Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
+ solbeskinnede.
+    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
+ og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
+ beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
+ får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
+ immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
+ avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
+ almissemedlemmer, 29 pensionister og rentenydere.
+    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
+ når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
+ idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
+ længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
+ forværredes sygdommen og han døde.


Property changes on: trunk/source/extra/uconv/samples/iso8859-1.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/koi8r.txt
===================================================================
--- trunk/source/extra/uconv/samples/koi8r.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/koi8r.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,6 +1,6 @@
-áÍÅÒÉËÁÎÓËÉÅ ÓÕÄÁ ÎÁÈÏÄÑÔÓÑ × ÍÅÖÄÕÎÁÒÏÄÎÙÈ ×ÏÄÁÈ. ñÐÏÎÉÑ
-×ÙÒÁÚÉÌÁ ÓÅÒØÅÚÎÏÅ ÂÅÓÐÏËÏÊÓÔ×Ï ÓÏ×ÅÔÓËÉÍÉ ÄÅÊÓÔ×ÉÑÍÉ.
-ðÅÎÔÁÇÏÎ ÂÅÓÐÏËÏÊÓÔ×Á ÎÅ ÐÒÏÑ×ÉÌ. óûá ÐÒÏ×ÏÄÑÔ ÐÏÄÏÂÎÏÅ ÓÌÅÖÅ-
-ÎÉÅ ÚÁ ÓÏ×ÅÔÓËÉÍÉ ÓÕÄÁÍÉ × ëÁÒÉÂÓËÏÍ ÍÏÒÅ. ðÒÁ×ÄÁ, ËÏÌÉÞÅÓÔ×Ï
-ÓÏ×ÅÔÓËÉÈ ÓÁÍÏÌÅÔÏ× ×ÙÚ×ÁÌÏ ÎÅËÏÔÏÒÏÅ ÕÄÉ×ÌÅÎÉÅ..
-
+áÍÅÒÉËÁÎÓËÉÅ ÓÕÄÁ ÎÁÈÏÄÑÔÓÑ × ÍÅÖÄÕÎÁÒÏÄÎÙÈ ×ÏÄÁÈ. ñÐÏÎÉÑ
+×ÙÒÁÚÉÌÁ ÓÅÒØÅÚÎÏÅ ÂÅÓÐÏËÏÊÓÔ×Ï ÓÏ×ÅÔÓËÉÍÉ ÄÅÊÓÔ×ÉÑÍÉ.
+ðÅÎÔÁÇÏÎ ÂÅÓÐÏËÏÊÓÔ×Á ÎÅ ÐÒÏÑ×ÉÌ. óûá ÐÒÏ×ÏÄÑÔ ÐÏÄÏÂÎÏÅ ÓÌÅÖÅ-
+ÎÉÅ ÚÁ ÓÏ×ÅÔÓËÉÍÉ ÓÕÄÁÍÉ × ëÁÒÉÂÓËÏÍ ÍÏÒÅ. ðÒÁ×ÄÁ, ËÏÌÉÞÅÓÔ×Ï
+ÓÏ×ÅÔÓËÉÈ ÓÁÍÏÌÅÔÏ× ×ÙÚ×ÁÌÏ ÎÅËÏÔÏÒÏÅ ÕÄÉ×ÌÅÎÉÅ..
+


Property changes on: trunk/source/extra/uconv/samples/koi8r.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/armenian.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/armenian.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/armenian.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,4 +1,4 @@
-Աեցեհի իմ լավ ?ւղիե լավարար,
-Ô¿ÕµÕ¡Õ¥Õ¢Õ½ Õ¹Õ¿Õ¡ÕµÕ« Õ¯Õ¡Õ½Õ¯Õ¡Õ®Õ« Õ´Õ°Õ£Õ«Õ¥...
-Ô±ÕµÕ¥ÕºÕ°Õ½ Õ¯?Ö‚Õ¦Õ°Õ« Õ´Õ°Õ¯Õ¥ Õ«Õ¥Õ® ?Õ¡Õ¾Õ¡Õ¿Ö€,
-Ô±ÕµÕ¥ÕºÕ°Õ½ Õ¯?Ö‚Õ¦Õ°Õ« ?Õ¡Õ¾Õ¡Õ¿Õ¡Õ¬ Õ´Õ°Õ¯Õ«Õ¥Ö‰
+Աեցեհի իմ լավ ?ւղիե լավարար,
+Ô¿ÕµÕ¡Õ¥Õ¢Õ½ Õ¹Õ¿Õ¡ÕµÕ« Õ¯Õ¡Õ½Õ¯Õ¡Õ®Õ« Õ´Õ°Õ£Õ«Õ¥...
+Ô±ÕµÕ¥ÕºÕ°Õ½ Õ¯?Ö‚Õ¦Õ°Õ« Õ´Õ°Õ¯Õ¥ Õ«Õ¥Õ® ?Õ¡Õ¾Õ¡Õ¿Ö€,
+Ô±ÕµÕ¥ÕºÕ°Õ½ Õ¯?Ö‚Õ¦Õ°Õ« ?Õ¡Õ¾Õ¡Õ¿Õ¡Õ¬ Õ´Õ°Õ¯Õ«Õ¥Ö‰


Property changes on: trunk/source/extra/uconv/samples/utf8/armenian.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/banviet.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/banviet.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/banviet.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,11 +1,11 @@
-Bần chỉ là một anh nghèo xác, ngày ngày lang-thang 
-khắp xóm này qua xóm khác xin ăn. Quần áo 
-rách-mướp Bần cũng chả coi sao, chân không có giầy và 
-đầu cũng chẳng có mũ. Giời nắng hay giời mưa Bần 
-không bao giờ quan-tâm. Một ngưòi như Bần thì ai cũng 
-tưởng là không còn có gì là quí-vât nữa. Thế nhưng ta 
-nhầm vì Bần có cái quạt mo, Bần quí lắm. Bần quí và giữ 
-luôn không rời bỏ bao giờ. Giời nắng thì Bần che đầu, 
-giời mưa Bần cũng nhờ nó mà đỡ ướt. Muốn ngồi Bần 
-dùng làm chiếu và đêm đến các chú muỗi vo-ve thì Bần 
-dùng để dánh đuổi các chú ấy.
+Bần chỉ là một anh nghèo xác, ngày ngày lang-thang 
+khắp xóm này qua xóm khác xin ăn. Quần áo 
+rách-mướp Bần cũng chả coi sao, chân không có giầy và 
+đầu cũng chẳng có mũ. Giời nắng hay giời mưa Bần 
+không bao giờ quan-tâm. Một ngưòi như Bần thì ai cũng 
+tưởng là không còn có gì là quí-vât nữa. Thế nhưng ta 
+nhầm vì Bần có cái quạt mo, Bần quí lắm. Bần quí và giữ 
+luôn không rời bỏ bao giờ. Giời nắng thì Bần che đầu, 
+giời mưa Bần cũng nhờ nó mà đỡ ướt. Muốn ngồi Bần 
+dùng làm chiếu và đêm đến các chú muỗi vo-ve thì Bần 
+dùng để dánh đuổi các chú ấy.


Property changes on: trunk/source/extra/uconv/samples/utf8/banviet.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/croat.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/croat.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/croat.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-Dobar dan! Kako ste? Ja sam Marina
-Dodigović. Kako se Vi zovete?
+Dobar dan! Kako ste? Ja sam Marina
+Dodigović. Kako se Vi zovete?


Property changes on: trunk/source/extra/uconv/samples/utf8/croat.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/danish.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/danish.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/danish.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,18 +1,18 @@
- Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
- (H. C. Andersens Hus, Odense).
-
-BARNDOMSOMGIVELSERNE</b>
- Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
- solbeskinnede.
-    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
- og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
- beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
- får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
- immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
- avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
- almissemedlemmer, 29 pensionister og rentenydere.
-    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
- når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
- idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
- længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
- forværredes sygdommen og han døde.
+ Foto ______ det formodede fødehus, hjørnet ______ Hans Jensensstræde og Bangs Boder.
+ (H. C. Andersens Hus, Odense).
+
+BARNDOMSOMGIVELSERNE</b>
+ Skønt H. C. Andersens barndomsomgivelser var meget fattige, blev de i hans rige fantasi
+ solbeskinnede.
+    Der findes en mandtalsliste fra nogle få år ______ H. C. Andersens fødsel. Den er ______ 1801
+ og den giver klare oplysninger om, hvor mange der boede ______ Odense og hvad de var
+ beskæftigede ______. Den omfatter 1199 husstande. Hvis man fordeler disse ______ erhverv,
+ får man 102 embeds- og bestillingsmænd, 26 officerer, 12 der beskæftiger sig med
+ immaterielle erhverv, 81 som lever ______ handel, 36 værtshusholdere, 460 håndværkere, 39
+ avlsmænd og urtemænd, 121 soldater, 97 daglejere, 139 enlige kvinder og
+ almissemedlemmer, 29 pensionister og rentenydere.
+    H. C. Andersens forældre tilhørte samfundets laveste lag. Faderen var friskomager, og
+ når han meldte sig ______ militærtjeneste ______ Napoleons side, har det nok ikke så meget været
+ idealisme som praktisk økonomi. For at sikre sig en soldats værgeløn. Han kom ikke
+ længere end ______ Holsten. Han fik høj feber og måtte sendes hjem. Da han kom hjem,
+ forværredes sygdommen og han døde.


Property changes on: trunk/source/extra/uconv/samples/utf8/danish.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/greek.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/greek.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/greek.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,44 +1,44 @@
-<html lang="gr" dir="ltr">
-<head>
-<meta http-equiv="content-type" content="text/html; charset=UNICODE-1-1-UTF-8">
-</head>
-<body>
-
-
-
-[σταρτ ηερε] ΓΕΝΕΣΙΣ 1-3
-Ψηαπτερ 1
-<br>
-1.
-ͲΕν αρχη εποιησεν ο θεος τον ουρανον και την γην.  
-<br>
-2.
-η δε γη ην  
-<br>
-αορατος και ακατασκευαστος, και σκοτος επανω της αβυσσου, και  
-<br>
-πνευμα θεου επεφερετο επανω του υδατος.  
-<br>
-3.
-και ειπεν ο θεος  
-<br>
-Γενηθητω φως. και εγενετο φως.  
-<br>
-4.
-και ειδεν ο θεος το φως οτι  
-<br>
-καλον. και διεχωρισεν ο θεος ανα μεσον του φωτος και ανα μεσον  
-<br>
-του σκοτους.  
-<br>
-5.
-και εκαλεσεν ο θεος το φως ημεραν και το σκοτος  
-<br>
-εκαλεσεν νυκτα. και εγενετο εσπερα και εγενετο πρωι, ημερα μια.  
-<br>
-
-
-</body>
-</html>
-
-
+<html lang="gr" dir="ltr">
+<head>
+<meta http-equiv="content-type" content="text/html; charset=UNICODE-1-1-UTF-8">
+</head>
+<body>
+
+
+
+[σταρτ ηερε] ΓΕΝΕΣΙΣ 1-3
+Ψηαπτερ 1
+<br>
+1.
+ͲΕν αρχη εποιησεν ο θεος τον ουρανον και την γην.  
+<br>
+2.
+η δε γη ην  
+<br>
+αορατος και ακατασκευαστος, και σκοτος επανω της αβυσσου, και  
+<br>
+πνευμα θεου επεφερετο επανω του υδατος.  
+<br>
+3.
+και ειπεν ο θεος  
+<br>
+Γενηθητω φως. και εγενετο φως.  
+<br>
+4.
+και ειδεν ο θεος το φως οτι  
+<br>
+καλον. και διεχωρισεν ο θεος ανα μεσον του φωτος και ανα μεσον  
+<br>
+του σκοτους.  
+<br>
+5.
+και εκαλεσεν ο θεος το φως ημεραν και το σκοτος  
+<br>
+εκαλεσεν νυκτα. και εγενετο εσπερα και εγενετο πρωι, ημερα μια.  
+<br>
+
+
+</body>
+</html>
+
+


Property changes on: trunk/source/extra/uconv/samples/utf8/greek.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/hangul.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/hangul.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/hangul.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-도서관
-한국
+도서관
+한국


Property changes on: trunk/source/extra/uconv/samples/utf8/hangul.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/hania.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/hania.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/hania.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,2 +1,2 @@
-圖書館 
+圖書館 
 韓國
\ No newline at end of file


Property changes on: trunk/source/extra/uconv/samples/utf8/hania.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/many.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/many.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/many.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,18 +1,18 @@
-外国語の勉強と教え
-Изучение и обучение иностранных языков
-語文教學・语文教学
-Enseñanza y estudio de idiomas
-Изучаване и Преподаване на Чужди Езипи
-ქართული ენის შესწავლა და სწავლება
-'læŋɡwidʒ 'lɘr:niŋ ænd 'ti:ʃiŋ
-Lus kawm thaib qhia
-Ngôn Ngữ, Sự học,
-‭‫ללמוד וללמד את השֵפה
-L'enseignement et l'étude des langues
-㜊㞕㧍㒟㦮 㐀㛲㭘㒟
-Nauka języków obcych
-Γλωσσική Εκμὰθηση και Διδασκαλία
-‭‫ﺗﺪﺭﯾﺲ ﻭ ﯾﺎﺩﮔﯿﺮﯼ ﺯﺑﺎﻥ
-Sprachlernen und -lehren
-‭‫ﺗﻌﻠ‫ُّ‪‫ﻢ ﻭﺗﺪﺭﻳﺲ ﺍﻟﻌﺮﺑﻴﺔ
-เรียนและสอนภาษา
+外国語の勉強と教え
+Изучение и обучение иностранных языков
+語文教學・语文教学
+Enseñanza y estudio de idiomas
+Изучаване и Преподаване на Чужди Езипи
+ქართული ენის შესწავლა და სწავლება
+'læŋɡwidʒ 'lɘr:niŋ ænd 'ti:ʃiŋ
+Lus kawm thaib qhia
+Ngôn Ngữ, Sự học,
+‭‫ללמוד וללמד את השֵפה
+L'enseignement et l'étude des langues
+㜊㞕㧍㒟㦮 㐀㛲㭘㒟
+Nauka języków obcych
+Γλωσσική Εκμὰθηση και Διδασκαλία
+‭‫ﺗﺪﺭﯾﺲ ﻭ ﯾﺎﺩﮔﯿﺮﯼ ﺯﺑﺎﻥ
+Sprachlernen und -lehren
+‭‫ﺗﻌﻠ‫ُّ‪‫ﻢ ﻭﺗﺪﺭﻳﺲ ﺍﻟﻌﺮﺑﻴﺔ
+เรียนและสอนภาษา


Property changes on: trunk/source/extra/uconv/samples/utf8/many.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/maopoem.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/maopoem.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/maopoem.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,23 +1,23 @@
-和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年
-    和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年.
-
-        久有归天愿
-        终过鬼门关
-        千里来寻归宿
-        春华变苍颜
-        到处群魔乱舞
-        更有妖雾盘绕
-        暗道入阴间
-        过了阎王殿
-        险处不须看
-
-        风雷动
-        旌旗奋
-        忆人寰
-        八十三年过去
-        弹指一挥间
-        中原千军逐蒋
-        城楼万众检阅
-        褒贬满载还
-        世上无难事
-        只怕我癫痫
+和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年
+    和毛泽东 <<重上井冈山>>. 严永欣, 一九八八年.
+
+        久有归天愿
+        终过鬼门关
+        千里来寻归宿
+        春华变苍颜
+        到处群魔乱舞
+        更有妖雾盘绕
+        暗道入阴间
+        过了阎王殿
+        险处不须看
+
+        风雷动
+        旌旗奋
+        忆人寰
+        八十三年过去
+        弹指一挥间
+        中原千军逐蒋
+        城楼万众检阅
+        褒贬满载还
+        世上无难事
+        只怕我癫痫


Property changes on: trunk/source/extra/uconv/samples/utf8/maopoem.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/turkish.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/turkish.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/turkish.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,6 +1,6 @@
-Yukarda mavi gök, asağıda yağız yer yaratıldıkta; ikisinin arasında insan
-oğlu yaratılmış. İnsan oğulları üzerine ecdadım Bumın hakan, İstemi hakan
-tahta oturmuş; oturarak Türk milletinin ülkesini, türesini, idare edivermiş,
-tanzim edivermis. Dört taraf hep düşman imiş. Asker sevk edip dört taraftaki
-kavmi hep (itaati altına) almış hep muti kılmış. Başlılara baş eğdirmiş,
-dizlilere diz çöktürmüş.
+Yukarda mavi gök, asağıda yağız yer yaratıldıkta; ikisinin arasında insan
+oğlu yaratılmış. İnsan oğulları üzerine ecdadım Bumın hakan, İstemi hakan
+tahta oturmuş; oturarak Türk milletinin ülkesini, türesini, idare edivermiş,
+tanzim edivermis. Dört taraf hep düşman imiş. Asker sevk edip dört taraftaki
+kavmi hep (itaati altına) almış hep muti kılmış. Başlılara baş eğdirmiş,
+dizlilere diz çöktürmüş.


Property changes on: trunk/source/extra/uconv/samples/utf8/turkish.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/samples/utf8/utf-8-demo.txt
===================================================================
--- trunk/source/extra/uconv/samples/utf8/utf-8-demo.txt	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/samples/utf8/utf-8-demo.txt	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,7 +1,7 @@
-UTF-8 encoded sample plain-text file
-‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
-This file is a place-holder. The original file is available from Markus Kuhn's website at http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt.
-
-Markus says this about copying files that are on his site:
-
-Please do not copy any of my publications onto your own Internet server for public access without explicit permission. If you want to refer to any of my texts, please use a hyperlink to my original and not a copy. I update some of the texts frequently and I want to prevent the confusion that arises if people read somewhere else obsolete versions that are not under my control.
+UTF-8 encoded sample plain-text file
+‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
+This file is a place-holder. The original file is available from Markus Kuhn's website at http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt.
+
+Markus says this about copying files that are on his site:
+
+Please do not copy any of my publications onto your own Internet server for public access without explicit permission. If you want to refer to any of my texts, please use a hyperlink to my original and not a copy. I update some of the texts frequently and I want to prevent the confusion that arises if people read somewhere else obsolete versions that are not under my control.


Property changes on: trunk/source/extra/uconv/samples/utf8/utf-8-demo.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/uconv.1.in
===================================================================
--- trunk/source/extra/uconv/uconv.1.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/uconv.1.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,449 +1,449 @@
-.\" Hey, Emacs! This is -*-nroff-*- you know...
-.\"
-.\" uconv.1: manual page for the uconv utility.
-.\"
-.\" Copyright (C) 2000-2005 IBM, Inc. and others.
-.\"
-.\" Manual page by Yves Arrouye <yves at realnames.com>.
-.\"
-.TH UCONV 1 "2005-jul-1" "ICU MANPAGE" "ICU @VERSION@ Manual"
-.SH NAME
-.B uconv
-\- convert data from one encoding to another
-.SH SYNOPSIS
-.B uconv
-[
-.BR "\-h\fP, \fB\-?\fP, \fB\-\-help"
-]
-[
-.BI "\-V\fP, \fB\-\-version"
-]
-[
-.BI "\-s\fP, \fB\-\-silent"
-]
-[
-.BI "\-v\fP, \fB\-\-verbose"
-]
-[
-.BI "\-l\fP, \fB\-\-list"
-|
-.BI "\-l\fP, \fB\-\-list\-code" " code"
-|
-.BI "\-\-default-code"
-|
-.BI "\-L\fP, \fB\-\-list\-transliterators"
-]
-[
-.BI "\-\-canon"
-]
-[
-.BI "\-x" " transliteration
-]
-[
-.BI "\-\-to\-callback" " callback"
-|
-.B "\-c"
-]
-[
-.BI "\-\-from\-callback" " callback"
-|
-.B "\-i"
-]
-[
-.BI "\-\-callback" " callback"
-]
-[
-.BI "\-\-fallback"
-|
-.BI "\-\-no\-fallback"
-]
-[
-.BI "\-b\fP, \fB\-\-block\-size" " size"
-]
-[
-.BI "\-f\fP, \fB\-\-from\-code" " encoding"
-]
-[
-.BI "\-t\fP, \fB\-\-to\-code" " encoding"
-]
-[
-.BI "\-\-add\-signature"
-]
-[
-.BI "\-\-remove\-signature"
-]
-[
-.BI "\-o\fP, \fB\-\-output" " file"
-]
-[
-.IR file .\|.\|.
-]
-.SH DESCRIPTION
-.B uconv
-converts, or transcodes, each given
-.I file
-(or its standard input if no
-.I file
-is specified) from one
-.I encoding
-to another. 
-The transcoding is done using Unicode as a pivot encoding
-(i.e. the data are first transcoded from their original encoding to
-Unicode, and then from Unicode to the destination encoding).
-.PP
-If an
-.I encoding
-is not specified or is
-.BR - ,
-the default encoding is used. Thus, calling
-.B uconv
-with no
-.I encoding
-provides an easy way to validate and sanitize data files for
-further consumption by tools requiring data in the default encoding.
-.PP
-When calling
-.BR uconv ,
-it is possible to specify callbacks that are used to handle invalid
-characters in the input, or characters that cannot be transcoded to
-the destination encoding. Some encodings, for example, offer a default
-substitution character that can be used to represent the occurence of
-such characters in the input. Other callbacks offer a useful visual
-representation of the invalid data.
-.PP
-.B uconv
-can also run the specified
-.IR transliteration
-on the transcoded data,
-in which case transliteration will happen as an intermediate step,
-after the data have been transcoded to Unicode.
-The
-.I transliteration
-can be either a list of semicolon-separated transliterator names,
-or an arbitrarily complex set of rules in the ICU transliteration
-rules format.
-.PP
-For transcoding purposes,
-.B uconv
-options are compatible with those of
-.BR iconv (1),
-making it easy to replace it in scripts. It is not necessarily the case,
-however, that the encoding names used by
-.B uconv
-and ICU are the same as the ones used by
-.BR iconv (1).
-Also, options that provide informational data, such as the
-.B \-l\fP, \fB\-\-list
-one offered by some 
-.BR iconv (1)
-variants such as GNU's, produce data in a slightly different and
-easier to parse format.
-.SH OPTIONS
-.TP
-.BR "\-h\fP, \fB\-?\fP, \fB\-\-help"
-Print help about usage and exit.
-.TP
-.BR "\-V\fP, \fB\-\-version"
-Print the version of
-.B uconv
-and exit.
-.TP
-.BI "\-s\fP, \fB\-\-silent"
-Suppress messages during execution.
-.TP
-.BI "\-v\fP, \fB\-\-verbose"
-Display extra informative messages during execution.
-.TP
-.BI "\-l\fP, \fB\-\-list"
-List all the available encodings and exit.
-.TP
-.BI "\-l\fP, \fB\-\-list\-code" " code"
-List only the
-.I code
-encoding and exit. If
-.I code
-is not a proper encoding, exit with an error.
-.TP
-.BI "\-\-default-code"
-List only the name of the default encoding and exit.
-.TP
-.BI "\-L\fP, \fB\-\-list\-transliterators"
-List all the available transliterators and exit.
-.TP
-.BI "\--canon"
-If used with
-.BI "\-l\fP, \fB\-\-list"
-or
-.BR "\-\-default-code" ,
-the list of encodings is produced in a format compatible with
-.BR convrtrs.txt (5).
-If used with
-.BR "\-L\fP, \fB\-\-list\-transliterators" ,
-print only one transliterator name per line.
-.TP
-.BI "\-x" " transliteration"
-Run the given
-.IR transliteration
-on the transcoded Unicode data,
-and use the transliterated data as input for the transcoding to
-the the destination encoding.
-.TP
-.BI "\-\-to\-callback" " callback"
-Use
-.I callback
-to handle characters that cannot be transcoded to the destination
-encoding. See section
-.B CALLBACKS
-for details on valid callbacks.
-.TP
-.B "\-c"
-Omit invalid characters from the output.
-Same as
-.BR "\-\-to\-callback skip" .
-.TP
-.BI "\-\-from\-callback" " callback"
-Use
-.I callback
-to handle characters that cannot be transcoded from the original
-encoding. See section
-.B CALLBACKS
-for details on valid callbacks.
-.TP
-.B "\-i"
-Ignore invalid sequences in the input.
-Same as
-.BR "\-\-from\-callback skip" .
-.TP
-.BI "\-\-callback" " callback"
-Use
-.I callback
-to handle both characters that cannot be transcoded from the original
-encoding and characters that cannot be transcoded to the destination
-encoding. See section
-.B CALLBACKS
-for details on valid callbacks.
-.TP
-.BI "\-\-fallback"
-Use the fallback mapping when transcoding from
-Unicode to the destination encoding.
-.TP
-.BI "\-\-no\-fallback"
-Do not use the fallback mapping when transcoding from Unicode to the
-destination encoding.
-This is the default.
-.TP
-.BI "\-b\fP, \fB\-\-block\-size" " size"
-Read input in blocks of
-.I size
-bytes at a time. The default block size is
-4096.
-.TP
-.BI "\-f\fP, \fB\-\-from\-code" " encoding"
-Set the original encoding of the data to 
-.IR encoding .
-.TP
-.BI "\-t\fP, \fB\-\-to\-code" " encoding"
-Transcode the data to
-.IR encoding .
-.TP
-.BI "\-\-add\-signature"
-Add a U+FEFF Unicode signature character (BOM) if the output charset
-supports it and does not add one anyway.
-.TP
-.BI "\-\-remove\-signature"
-Remove a U+FEFF Unicode signature character (BOM).
-.TP
-.BI "\-o\fP, \fB\-\-output" " file"
-Write the transcoded data to
-.IR file .
-.SH CALLBACKS
-.B uconv
-supports specifying callbacks to handle invalid data. Callbacks can be
-set for both directions of transcoding: from the original encoding to
-Unicode, with the
-.BR "\-\-from\-callback"
-option, and from Unicode to the destination encoding, with the
-.BR "\-\-to\-callback"
-option.
-.PP
-The following is a list of valid
-.I callback
-names, alonmg with a description of their behavior. The list of
-callbacks actually supported by
-.B uconv
-is displayed when it is called with
-.BR "\-h\fP, \fB\-\-help" .
-.PP
-.TP \w'\fBescape-unicode'u+3n
-.B substitute
-Write the the encoding's substitute sequence, or the Unicode
-replacement character
-.B U+FFFD
-when transcoding to Unicode.
-.TP
-.B skip
-Ignore the invalid data.
-.TP
-.B stop
-Stop with an error when encountering invalid data.
-This is the default callback.
-.TP
-.B escape
-Same as
-.BR escape-icu .
-.TP
-.B escape-icu
-Replace the missing characters with a string of the format
-.BR %U\fIhhhh\fP
-for plane 0 characters, and
-.BR %U\fIhhhh\fP%U\fIhhhh\fP
-for planes 1 and above characters,
-where
-.I hhhh
-is the hexadecimal value of one of the UTF-16 code units representing the
-character. Characters from planes 1 and above are written as a pair of
-UTF-16 surrogate code units.
-.TP
-.B escape-java
-Replace the missing characters with a string of the format
-.BR \eu\fIhhhh\fP
-for plane 0 characters, and
-.BR \eu\fIhhhh\fP\eu\fIhhhh\fP
-for planes 1 and above characters,
-where
-.I hhhh
-is the hexadecimal value of one of the UTF-16 code units representing the
-character. Characters from planes 1 and above are written as a pair of
-UTF-16 surrogate code units.
-.TP
-.B escape-c
-Replace the missing characters with a string of the format
-.BR \eu\fIhhhh\fP
-for plane 0 characters, and
-.BR \eU\fIhhhhhhhh\fP
-for planes 1 and above characters,
-where
-.I hhhh
-and
-.I hhhhhhhh
-are the hexadecimal values of the Unicode codepoint.
-.TP
-.B escape-xml
-Same as
-.BR escape-xml-hex .
-.TP
-.B escape-xml-hex
-Replace the missing characters with a string of the format
-.BR &#x\fIhhhh\fP; ,
-where
-.I hhhh
-is the hexadecimal value of the Unicode codepoint.
-.TP
-.B escape-xml-dec
-Replace the missing characters with a string of the format
-.BR &#x\fInnnn\fP; ,
-where
-.I nnnn
-is the decimal value of the Unicode codepoint.
-.TP
-.B escape-unicode
-Replace the missing characters with a string of the format
-.BR {U+\fIhhhh\fP} ,
-where
-.I hhhh
-is the hexadecimal value of the Unicode codepoint.
-That hexadecimal string is of variable length and can use from 4 to
-6 digits.
-This is the format universally used to denote a Unicode codepoint in
-the litterature, delimited by curly braces for easy recognition of those
-substitutions in the output.
-.SH EXAMPLES
-Convert data from a given
-.I encoding
-to the platform encoding:
-
-.RS 4
-.B \fR$ \fPuconv \-f \fIencoding\fP
-.RE
-.PP
-Check if a
-.I file
-contains valid data for a given
-.IR encoding :
-
-.RS 4
-.B \fR$ \fPuconv \-f \fIencoding\fP \-c \fIfile\fP >/dev/null
-.RE
-.PP
-Convert a UTF-8
-.I file
-to a given
-.I encoding
-and ensure that the resulting text is good for any version of HTML:
-
-.RS 4
-.B \fR$ \fPuconv \-f utf-8 \-t \fIencoding\fP \e
-.br
-.B "    \-\-callback escape-xml-dec \fIfile\fP"
-.RE
-.PP
-Display the names of the Unicode code points in a UTF-file:
-
-.RS 4
-.B \fR$ \fPuconv \-f utf-8 \-x any-name \fIfile\fP
-.RE
-.PP
-Print the name of a Unicode code point whose value is known (\fBU+30AB\fP
-in this example):
-
-.RS 4
-.B \fR$ \fPecho '\eu30ab' | uconv \-x 'hex-any; any-name'; echo
-.br
-{KATAKANA LETTER KA}{LINE FEED}
-.br
-$ 
-.RE
-
-(The names are delimited by curly braces.
-Also, the name of the line terminator is also displayed.)
-.PP
-Normalize UTF-8 data using Unicode NFKC, remove all control characters,
-and map Katakana to Hiragana:
-
-.RS 4
-.B \fR$ \fPuconv \-f utf-8 \-t utf-8 \e
-.br
-.B "      \-x '::nfkc; [:Cc:] >; ::katakana-hiragana;'"
-.SH CAVEATS AND BUGS
-.B uconv
-does report errors as occuring at the first invalid byte
-encountered. This may be confusing to users of GNU
-.BR iconv (1),
-which reports errors as occuring at the first byte of an invalid
-sequence. For multi-byte character sets or encodings, this means that
-.BR uconv
-error positions may be at a later offset in the input stream than
-would be the case with GNU
-.BR iconv (1).
-.PP
-The reporting of error positions when a transliterator is used may be
-inaccurate or unavailable, in which case
-.BR uconv
-will report the offset in the output stream at which the error
-occured.
-.\" .SH FILES
-.\" .TP 15
-.\" .B @pkgicudatadir@/@PACKAGE@/@VERSION@/uconvmsg.dat
-.\" Compiled resource bundle containing localized messages printed
-.\" by
-.\" .BR uconv .
-.SH AUTHORS
-Jonas Utterstroem
-.br
-Yves Arrouye
-.SH VERSION
- at VERSION@
-.SH COPYRIGHT
-Copyright (C) 2000-2005 IBM, Inc. and others.
-.SH SEE ALSO
-.BR iconv (1)
+.\" Hey, Emacs! This is -*-nroff-*- you know...
+.\"
+.\" uconv.1: manual page for the uconv utility.
+.\"
+.\" Copyright (C) 2000-2005 IBM, Inc. and others.
+.\"
+.\" Manual page by Yves Arrouye <yves at realnames.com>.
+.\"
+.TH UCONV 1 "2005-jul-1" "ICU MANPAGE" "ICU @VERSION@ Manual"
+.SH NAME
+.B uconv
+\- convert data from one encoding to another
+.SH SYNOPSIS
+.B uconv
+[
+.BR "\-h\fP, \fB\-?\fP, \fB\-\-help"
+]
+[
+.BI "\-V\fP, \fB\-\-version"
+]
+[
+.BI "\-s\fP, \fB\-\-silent"
+]
+[
+.BI "\-v\fP, \fB\-\-verbose"
+]
+[
+.BI "\-l\fP, \fB\-\-list"
+|
+.BI "\-l\fP, \fB\-\-list\-code" " code"
+|
+.BI "\-\-default-code"
+|
+.BI "\-L\fP, \fB\-\-list\-transliterators"
+]
+[
+.BI "\-\-canon"
+]
+[
+.BI "\-x" " transliteration
+]
+[
+.BI "\-\-to\-callback" " callback"
+|
+.B "\-c"
+]
+[
+.BI "\-\-from\-callback" " callback"
+|
+.B "\-i"
+]
+[
+.BI "\-\-callback" " callback"
+]
+[
+.BI "\-\-fallback"
+|
+.BI "\-\-no\-fallback"
+]
+[
+.BI "\-b\fP, \fB\-\-block\-size" " size"
+]
+[
+.BI "\-f\fP, \fB\-\-from\-code" " encoding"
+]
+[
+.BI "\-t\fP, \fB\-\-to\-code" " encoding"
+]
+[
+.BI "\-\-add\-signature"
+]
+[
+.BI "\-\-remove\-signature"
+]
+[
+.BI "\-o\fP, \fB\-\-output" " file"
+]
+[
+.IR file .\|.\|.
+]
+.SH DESCRIPTION
+.B uconv
+converts, or transcodes, each given
+.I file
+(or its standard input if no
+.I file
+is specified) from one
+.I encoding
+to another. 
+The transcoding is done using Unicode as a pivot encoding
+(i.e. the data are first transcoded from their original encoding to
+Unicode, and then from Unicode to the destination encoding).
+.PP
+If an
+.I encoding
+is not specified or is
+.BR - ,
+the default encoding is used. Thus, calling
+.B uconv
+with no
+.I encoding
+provides an easy way to validate and sanitize data files for
+further consumption by tools requiring data in the default encoding.
+.PP
+When calling
+.BR uconv ,
+it is possible to specify callbacks that are used to handle invalid
+characters in the input, or characters that cannot be transcoded to
+the destination encoding. Some encodings, for example, offer a default
+substitution character that can be used to represent the occurence of
+such characters in the input. Other callbacks offer a useful visual
+representation of the invalid data.
+.PP
+.B uconv
+can also run the specified
+.IR transliteration
+on the transcoded data,
+in which case transliteration will happen as an intermediate step,
+after the data have been transcoded to Unicode.
+The
+.I transliteration
+can be either a list of semicolon-separated transliterator names,
+or an arbitrarily complex set of rules in the ICU transliteration
+rules format.
+.PP
+For transcoding purposes,
+.B uconv
+options are compatible with those of
+.BR iconv (1),
+making it easy to replace it in scripts. It is not necessarily the case,
+however, that the encoding names used by
+.B uconv
+and ICU are the same as the ones used by
+.BR iconv (1).
+Also, options that provide informational data, such as the
+.B \-l\fP, \fB\-\-list
+one offered by some 
+.BR iconv (1)
+variants such as GNU's, produce data in a slightly different and
+easier to parse format.
+.SH OPTIONS
+.TP
+.BR "\-h\fP, \fB\-?\fP, \fB\-\-help"
+Print help about usage and exit.
+.TP
+.BR "\-V\fP, \fB\-\-version"
+Print the version of
+.B uconv
+and exit.
+.TP
+.BI "\-s\fP, \fB\-\-silent"
+Suppress messages during execution.
+.TP
+.BI "\-v\fP, \fB\-\-verbose"
+Display extra informative messages during execution.
+.TP
+.BI "\-l\fP, \fB\-\-list"
+List all the available encodings and exit.
+.TP
+.BI "\-l\fP, \fB\-\-list\-code" " code"
+List only the
+.I code
+encoding and exit. If
+.I code
+is not a proper encoding, exit with an error.
+.TP
+.BI "\-\-default-code"
+List only the name of the default encoding and exit.
+.TP
+.BI "\-L\fP, \fB\-\-list\-transliterators"
+List all the available transliterators and exit.
+.TP
+.BI "\--canon"
+If used with
+.BI "\-l\fP, \fB\-\-list"
+or
+.BR "\-\-default-code" ,
+the list of encodings is produced in a format compatible with
+.BR convrtrs.txt (5).
+If used with
+.BR "\-L\fP, \fB\-\-list\-transliterators" ,
+print only one transliterator name per line.
+.TP
+.BI "\-x" " transliteration"
+Run the given
+.IR transliteration
+on the transcoded Unicode data,
+and use the transliterated data as input for the transcoding to
+the the destination encoding.
+.TP
+.BI "\-\-to\-callback" " callback"
+Use
+.I callback
+to handle characters that cannot be transcoded to the destination
+encoding. See section
+.B CALLBACKS
+for details on valid callbacks.
+.TP
+.B "\-c"
+Omit invalid characters from the output.
+Same as
+.BR "\-\-to\-callback skip" .
+.TP
+.BI "\-\-from\-callback" " callback"
+Use
+.I callback
+to handle characters that cannot be transcoded from the original
+encoding. See section
+.B CALLBACKS
+for details on valid callbacks.
+.TP
+.B "\-i"
+Ignore invalid sequences in the input.
+Same as
+.BR "\-\-from\-callback skip" .
+.TP
+.BI "\-\-callback" " callback"
+Use
+.I callback
+to handle both characters that cannot be transcoded from the original
+encoding and characters that cannot be transcoded to the destination
+encoding. See section
+.B CALLBACKS
+for details on valid callbacks.
+.TP
+.BI "\-\-fallback"
+Use the fallback mapping when transcoding from
+Unicode to the destination encoding.
+.TP
+.BI "\-\-no\-fallback"
+Do not use the fallback mapping when transcoding from Unicode to the
+destination encoding.
+This is the default.
+.TP
+.BI "\-b\fP, \fB\-\-block\-size" " size"
+Read input in blocks of
+.I size
+bytes at a time. The default block size is
+4096.
+.TP
+.BI "\-f\fP, \fB\-\-from\-code" " encoding"
+Set the original encoding of the data to 
+.IR encoding .
+.TP
+.BI "\-t\fP, \fB\-\-to\-code" " encoding"
+Transcode the data to
+.IR encoding .
+.TP
+.BI "\-\-add\-signature"
+Add a U+FEFF Unicode signature character (BOM) if the output charset
+supports it and does not add one anyway.
+.TP
+.BI "\-\-remove\-signature"
+Remove a U+FEFF Unicode signature character (BOM).
+.TP
+.BI "\-o\fP, \fB\-\-output" " file"
+Write the transcoded data to
+.IR file .
+.SH CALLBACKS
+.B uconv
+supports specifying callbacks to handle invalid data. Callbacks can be
+set for both directions of transcoding: from the original encoding to
+Unicode, with the
+.BR "\-\-from\-callback"
+option, and from Unicode to the destination encoding, with the
+.BR "\-\-to\-callback"
+option.
+.PP
+The following is a list of valid
+.I callback
+names, alonmg with a description of their behavior. The list of
+callbacks actually supported by
+.B uconv
+is displayed when it is called with
+.BR "\-h\fP, \fB\-\-help" .
+.PP
+.TP \w'\fBescape-unicode'u+3n
+.B substitute
+Write the the encoding's substitute sequence, or the Unicode
+replacement character
+.B U+FFFD
+when transcoding to Unicode.
+.TP
+.B skip
+Ignore the invalid data.
+.TP
+.B stop
+Stop with an error when encountering invalid data.
+This is the default callback.
+.TP
+.B escape
+Same as
+.BR escape-icu .
+.TP
+.B escape-icu
+Replace the missing characters with a string of the format
+.BR %U\fIhhhh\fP
+for plane 0 characters, and
+.BR %U\fIhhhh\fP%U\fIhhhh\fP
+for planes 1 and above characters,
+where
+.I hhhh
+is the hexadecimal value of one of the UTF-16 code units representing the
+character. Characters from planes 1 and above are written as a pair of
+UTF-16 surrogate code units.
+.TP
+.B escape-java
+Replace the missing characters with a string of the format
+.BR \eu\fIhhhh\fP
+for plane 0 characters, and
+.BR \eu\fIhhhh\fP\eu\fIhhhh\fP
+for planes 1 and above characters,
+where
+.I hhhh
+is the hexadecimal value of one of the UTF-16 code units representing the
+character. Characters from planes 1 and above are written as a pair of
+UTF-16 surrogate code units.
+.TP
+.B escape-c
+Replace the missing characters with a string of the format
+.BR \eu\fIhhhh\fP
+for plane 0 characters, and
+.BR \eU\fIhhhhhhhh\fP
+for planes 1 and above characters,
+where
+.I hhhh
+and
+.I hhhhhhhh
+are the hexadecimal values of the Unicode codepoint.
+.TP
+.B escape-xml
+Same as
+.BR escape-xml-hex .
+.TP
+.B escape-xml-hex
+Replace the missing characters with a string of the format
+.BR &#x\fIhhhh\fP; ,
+where
+.I hhhh
+is the hexadecimal value of the Unicode codepoint.
+.TP
+.B escape-xml-dec
+Replace the missing characters with a string of the format
+.BR &#x\fInnnn\fP; ,
+where
+.I nnnn
+is the decimal value of the Unicode codepoint.
+.TP
+.B escape-unicode
+Replace the missing characters with a string of the format
+.BR {U+\fIhhhh\fP} ,
+where
+.I hhhh
+is the hexadecimal value of the Unicode codepoint.
+That hexadecimal string is of variable length and can use from 4 to
+6 digits.
+This is the format universally used to denote a Unicode codepoint in
+the litterature, delimited by curly braces for easy recognition of those
+substitutions in the output.
+.SH EXAMPLES
+Convert data from a given
+.I encoding
+to the platform encoding:
+
+.RS 4
+.B \fR$ \fPuconv \-f \fIencoding\fP
+.RE
+.PP
+Check if a
+.I file
+contains valid data for a given
+.IR encoding :
+
+.RS 4
+.B \fR$ \fPuconv \-f \fIencoding\fP \-c \fIfile\fP >/dev/null
+.RE
+.PP
+Convert a UTF-8
+.I file
+to a given
+.I encoding
+and ensure that the resulting text is good for any version of HTML:
+
+.RS 4
+.B \fR$ \fPuconv \-f utf-8 \-t \fIencoding\fP \e
+.br
+.B "    \-\-callback escape-xml-dec \fIfile\fP"
+.RE
+.PP
+Display the names of the Unicode code points in a UTF-file:
+
+.RS 4
+.B \fR$ \fPuconv \-f utf-8 \-x any-name \fIfile\fP
+.RE
+.PP
+Print the name of a Unicode code point whose value is known (\fBU+30AB\fP
+in this example):
+
+.RS 4
+.B \fR$ \fPecho '\eu30ab' | uconv \-x 'hex-any; any-name'; echo
+.br
+{KATAKANA LETTER KA}{LINE FEED}
+.br
+$ 
+.RE
+
+(The names are delimited by curly braces.
+Also, the name of the line terminator is also displayed.)
+.PP
+Normalize UTF-8 data using Unicode NFKC, remove all control characters,
+and map Katakana to Hiragana:
+
+.RS 4
+.B \fR$ \fPuconv \-f utf-8 \-t utf-8 \e
+.br
+.B "      \-x '::nfkc; [:Cc:] >; ::katakana-hiragana;'"
+.SH CAVEATS AND BUGS
+.B uconv
+does report errors as occuring at the first invalid byte
+encountered. This may be confusing to users of GNU
+.BR iconv (1),
+which reports errors as occuring at the first byte of an invalid
+sequence. For multi-byte character sets or encodings, this means that
+.BR uconv
+error positions may be at a later offset in the input stream than
+would be the case with GNU
+.BR iconv (1).
+.PP
+The reporting of error positions when a transliterator is used may be
+inaccurate or unavailable, in which case
+.BR uconv
+will report the offset in the output stream at which the error
+occured.
+.\" .SH FILES
+.\" .TP 15
+.\" .B @pkgicudatadir@/@PACKAGE@/@VERSION@/uconvmsg.dat
+.\" Compiled resource bundle containing localized messages printed
+.\" by
+.\" .BR uconv .
+.SH AUTHORS
+Jonas Utterstroem
+.br
+Yves Arrouye
+.SH VERSION
+ at VERSION@
+.SH COPYRIGHT
+Copyright (C) 2000-2005 IBM, Inc. and others.
+.SH SEE ALSO
+.BR iconv (1)


Property changes on: trunk/source/extra/uconv/uconv.1.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/uconv.cpp
===================================================================
--- trunk/source/extra/uconv/uconv.cpp	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/uconv.cpp	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,1409 +1,1409 @@
-/*****************************************************************************
-*
-*   Copyright (C) 1999-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************/
-
-/*
- * uconv(1): an iconv(1)-like converter using ICU.
- *
- * Original code by Jonas Utterstr&#x00F6;m <jonas.utterstrom at vittran.norrnod.se>
- * contributed in 1999.
- *
- * Conversion to the C conversion API and many improvements by
- * Yves Arrouye <yves at realnames.com>, current maintainer.
- *
- * Markus Scherer maintainer from 2003.
- * See source code repository history for changes.
- */
-
-#include <unicode/utypes.h>
-#include <unicode/putil.h>
-#include <unicode/ucnv.h>
-#include <unicode/uenum.h>
-#include <unicode/unistr.h>
-#include <unicode/translit.h>
-#include <unicode/uset.h>
-#include <unicode/uclean.h>
-
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <stdlib.h>
-
-#include "cmemory.h"
-#include "cstring.h"
-#include "ustrfmt.h"
-
-#include "unicode/uwmsg.h"
-
-#if (defined(U_WINDOWS) || defined(U_CYGWIN)) && !defined(__STRICT_ANSI__)
-#include <io.h>
-#include <fcntl.h>
-#if defined(U_WINDOWS)
-#define USE_FILENO_BINARY_MODE 1
-/* Windows likes to rename Unix-like functions */
-#ifndef fileno
-#define fileno _fileno
-#endif
-#ifndef setmode
-#define setmode _setmode
-#endif
-#ifndef O_BINARY
-#define O_BINARY _O_BINARY
-#endif
-#endif
-#endif
-
-#ifdef UCONVMSG_LINK
-/* below from the README */
-#include "unicode/utypes.h"
-#include "unicode/udata.h"
-U_CFUNC char uconvmsg_dat[];
-#endif
-
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
-#define DEFAULT_BUFSZ   4096
-#define UCONVMSG "uconvmsg"
-
-static UResourceBundle *gBundle = 0;    /* Bundle containing messages. */
-
-/*
- * Initialize the message bundle so that message strings can be fetched
- * by u_wmsg().
- *
- */
-
-static void initMsg(const char *pname) {
-    static int ps = 0;
-
-    if (!ps) {
-        char dataPath[2048];        /* XXX Sloppy: should be PATH_MAX. */
-        UErrorCode err = U_ZERO_ERROR;
-
-        ps = 1;
-
-        /* Set up our static data - if any */
-#ifdef UCONVMSG_LINK
-        udata_setAppData(UCONVMSG, (const void*) uconvmsg_dat, &err);
-        if (U_FAILURE(err)) {
-          fprintf(stderr, "%s: warning, problem installing our static resource bundle data uconvmsg: %s - trying anyways.\n",
-                  pname, u_errorName(err));
-          err = U_ZERO_ERROR; /* It may still fail */
-        }
-#endif
-
-        /* Get messages. */
-        gBundle = u_wmsg_setPath(UCONVMSG, &err);
-        if (U_FAILURE(err)) {
-            fprintf(stderr,
-                    "%s: warning: couldn't open bundle %s: %s\n",
-                    pname, UCONVMSG, u_errorName(err));
-#ifdef UCONVMSG_LINK
-            fprintf(stderr,
-                    "%s: setAppData was called, internal data %s failed to load\n",
-                        pname, UCONVMSG);
-#endif
- 
-            err = U_ZERO_ERROR;
-            /* that was try #1, try again with a path */
-            uprv_strcpy(dataPath, u_getDataDirectory());
-            uprv_strcat(dataPath, U_FILE_SEP_STRING);
-            uprv_strcat(dataPath, UCONVMSG);
-
-            gBundle = u_wmsg_setPath(dataPath, &err);
-            if (U_FAILURE(err)) {
-                fprintf(stderr,
-                    "%s: warning: still couldn't open bundle %s: %s\n",
-                    pname, dataPath, u_errorName(err));
-                fprintf(stderr, "%s: warning: messages will not be displayed\n", pname);
-            }
-        }
-    }
-}
-
-/* Mapping of callback names to the callbacks passed to the converter
-   API. */
-
-static struct callback_ent {
-    const char *name;
-    UConverterFromUCallback fromu;
-    const void *fromuctxt;
-    UConverterToUCallback tou;
-    const void *touctxt;
-} transcode_callbacks[] = {
-    { "substitute",
-      UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0,
-      UCNV_TO_U_CALLBACK_SUBSTITUTE, 0 },
-    { "skip",
-      UCNV_FROM_U_CALLBACK_SKIP, 0,
-      UCNV_TO_U_CALLBACK_SKIP, 0 },
-    { "stop",
-      UCNV_FROM_U_CALLBACK_STOP, 0,
-      UCNV_TO_U_CALLBACK_STOP, 0 },
-    { "escape",
-      UCNV_FROM_U_CALLBACK_ESCAPE, 0,
-      UCNV_TO_U_CALLBACK_ESCAPE, 0},
-    { "escape-icu",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_ICU,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_ICU },
-    { "escape-java",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_JAVA,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_JAVA },
-    { "escape-c",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C },
-    { "escape-xml",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX },
-    { "escape-xml-hex",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX },
-    { "escape-xml-dec",
-      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC },
-    { "escape-unicode", UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_UNICODE,
-      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_UNICODE }
-};
-
-/* Return a pointer to a callback record given its name. */
-
-static const struct callback_ent *findCallback(const char *name) {
-    int i, count =
-        sizeof(transcode_callbacks) / sizeof(*transcode_callbacks);
-
-    /* We'll do a linear search, there aren't many of them and bsearch()
-       may not be that portable. */
-
-    for (i = 0; i < count; ++i) {
-        if (!uprv_stricmp(name, transcode_callbacks[i].name)) {
-            return &transcode_callbacks[i];
-        }
-    }
-
-    return 0;
-}
-
-/* Print converter information. If lookfor is set, only that converter will
-   be printed, otherwise all converters will be printed. If canon is non
-   zero, tags and aliases for each converter are printed too, in the format
-   expected for convrters.txt(5). */
-
-static int printConverters(const char *pname, const char *lookfor,
-    UBool canon)
-{
-    UErrorCode err = U_ZERO_ERROR;
-    int32_t num;
-    uint16_t num_stds;
-    const char **stds;
-
-    /* If there is a specified name, just handle that now. */
-
-    if (lookfor) {
-        if (!canon) {
-            printf("%s\n", lookfor);
-            return 0;
-        } else {
-        /*  Because we are printing a canonical name, we need the
-            true converter name. We've done that already except for
-            the default name (because we want to print the exact
-            name one would get when calling ucnv_getDefaultName()
-            in non-canon mode). But since we do not know at this
-            point if we have the default name or something else, we
-            need to normalize again to the canonical converter
-            name. */
-
-            const char *truename = ucnv_getAlias(lookfor, 0, &err);
-            if (U_SUCCESS(err)) {
-                lookfor = truename;
-            } else {
-                err = U_ZERO_ERROR;
-            }
-        }
-    }
-
-    /* Print converter names. We come here for one of two reasons: we
-       are printing all the names (lookfor was null), or we have a
-       single converter to print but in canon mode, hence we need to
-       get to it in order to print everything. */
-
-    num = ucnv_countAvailable();
-    if (num <= 0) {
-        initMsg(pname);
-        u_wmsg(stderr, "cantGetNames");
-        return -1;
-    }
-    if (lookfor) {
-        num = 1;                /* We know where we want to be. */
-    }
-
-    num_stds = ucnv_countStandards();
-    stds = (const char **) uprv_malloc(num_stds * sizeof(*stds));
-    if (!stds) {
-        u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(U_MEMORY_ALLOCATION_ERROR));
-        return -1;
-    } else {
-        uint16_t s;
-
-        if (canon) {
-            printf("{ ");
-        }
-        for (s = 0; s < num_stds; ++s) {
-            stds[s] = ucnv_getStandard(s, &err);
-            if (canon) {
-                printf("%s ", stds[s]);
-            }
-            if (U_FAILURE(err)) {
-                u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(err));
-                return -1;
-            }
-        }
-        if (canon) {
-            puts("}");
-        }
-    }
-
-    for (int32_t i = 0; i < num; i++) {
-        const char *name;
-        uint16_t num_aliases;
-
-        /* Set the name either to what we are looking for, or
-        to the current converter name. */
-
-        if (lookfor) {
-            name = lookfor;
-        } else {
-            name = ucnv_getAvailableName(i);
-        }
-
-        /* Get all the aliases associated to the name. */
-
-        err = U_ZERO_ERROR;
-        num_aliases = ucnv_countAliases(name, &err);
-        if (U_FAILURE(err)) {
-            printf("%s", name);
-
-            UnicodeString str(name, "");
-            putchar('\t');
-            u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
-                u_wmsg_errorName(err));
-            return -1;
-        } else {
-            uint16_t a, s, t;
-
-            /* Write all the aliases and their tags. */
-
-            for (a = 0; a < num_aliases; ++a) {
-                const char *alias = ucnv_getAlias(name, a, &err);
-
-                if (U_FAILURE(err)) {
-                    UnicodeString str(name, "");
-                    putchar('\t');
-                    u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
-                        u_wmsg_errorName(err));
-                    return -1;
-                }
-
-                /* Print the current alias so that it looks right. */
-                printf("%s%s%s", (canon ? (a == 0? "" : "\t" ) : "") ,
-                                 alias,
-                                 (canon ? "" : " "));
-
-                /* Look (slowly, linear searching) for a tag. */
-
-                if (canon) {
-                    /* -1 to skip the last standard */
-                    for (s = t = 0; s < num_stds-1; ++s) {
-                        UEnumeration *nameEnum = ucnv_openStandardNames(name, stds[s], &err);
-                        if (U_SUCCESS(err)) {
-                            /* List the standard tags */
-                            const char *standardName;
-                            UBool isFirst = TRUE;
-                            UErrorCode enumError = U_ZERO_ERROR;
-                            while ((standardName = uenum_next(nameEnum, NULL, &enumError))) {
-                                /* See if this alias is supported by this standard. */
-                                if (!strcmp(standardName, alias)) {
-                                    if (!t) {
-                                        printf(" {");
-                                        t = 1;
-                                    }
-                                    /* Print a * after the default standard name */
-                                    printf(" %s%s", stds[s], (isFirst ? "*" : ""));
-                                }
-                                isFirst = FALSE;
-                            }
-                        }
-                    }
-                    if (t) {
-                        printf(" }");
-                    }
-                }
-                /* Terminate this entry. */
-                if (canon) {
-                    puts("");
-                }
-
-                /* Move on. */
-            }
-            /* Terminate this entry. */
-            if (!canon) {
-                puts("");
-            }
-        }
-    }
-
-    /* Free temporary data. */
-
-    uprv_free(stds);
-
-    /* Success. */
-
-    return 0;
-}
-
-/* Print all available transliterators. If canon is non zero, print
-   one transliterator per line. */
-
-static int printTransliterators(UBool canon)
-{
-#if UCONFIG_NO_TRANSLITERATION
-    printf("no transliterators available because of UCONFIG_NO_TRANSLITERATION, see uconfig.h\n");
-    return 1;
-#else
-    int32_t numtrans = utrans_countAvailableIDs(), i;
-    int buflen = 512;
-    char *buf = (char *) uprv_malloc(buflen);
-    char staticbuf[512];
-
-    char sepchar = canon ? '\n' : ' ';
-
-    if (!buf) {
-        buf = staticbuf;
-        buflen = sizeof(staticbuf);
-    }
-
-    for (i = 0; i < numtrans; ++i) {
-        int32_t len = utrans_getAvailableID(i, buf, buflen);
-        if (len >= buflen - 1) {
-            if (buf != staticbuf) {
-                buflen <<= 1;
-                if (buflen < len) {
-                    buflen = len + 64;
-                }
-                buf = (char *) uprv_realloc(buf, buflen);
-                if (!buf) {
-                    buf = staticbuf;
-                    buflen = sizeof(staticbuf);
-                }
-            }
-            utrans_getAvailableID(i, buf, buflen);
-            if (len >= buflen) {
-                uprv_strcpy(buf + buflen - 4, "..."); /* Truncate the name. */
-            }
-        }
-
-        printf("%s", buf);
-        if (i < numtrans - 1) {
-            putchar(sepchar);
-        }
-    }
-
-    /* Add a terminating newline if needed. */
-
-    if (sepchar != '\n') {
-        putchar('\n');
-    }
-
-    /* Free temporary data. */
-
-    if (buf != staticbuf) {
-        uprv_free(buf);
-    }
-
-    /* Success. */
-
-    return 0;
-#endif
-}
-
-enum {
-    uSP = 0x20,         // space
-    uCR = 0xd,          // carriage return
-    uLF = 0xa,          // line feed
-    uNL = 0x85,         // newline
-    uLS = 0x2028,       // line separator
-    uPS = 0x2029,       // paragraph separator
-    uSig = 0xfeff       // signature/BOM character
-};
-
-static inline int32_t
-getChunkLimit(const UnicodeString &prev, const UnicodeString &s) {
-    // find one of
-    // CR, LF, CRLF, NL, LS, PS
-    // for paragraph ends (see UAX #13/Unicode 4)
-    // and include it in the chunk
-    // all of these characters are on the BMP
-    // do not include FF or VT in case they are part of a paragraph
-    // (important for bidi contexts)
-    static const UChar paraEnds[] = {
-        0xd, 0xa, 0x85, 0x2028, 0x2029
-    };
-    enum {
-        iCR, iLF, iNL, iLS, iPS, iCount
-    };
-
-    // first, see if there is a CRLF split between prev and s
-    if (prev.endsWith(paraEnds + iCR, 1)) {
-        if (s.startsWith(paraEnds + iLF, 1)) {
-            return 1; // split CRLF, include the LF
-        } else if (!s.isEmpty()) {
-            return 0; // complete the last chunk
-        } else {
-            return -1; // wait for actual further contents to arrive
-        }
-    }
-
-    const UChar *u = s.getBuffer(), *limit = u + s.length();
-    UChar c;
-
-    while (u < limit) {
-        c = *u++;
-        if (
-            ((c < uSP) && (c == uCR || c == uLF)) ||
-            (c == uNL) ||
-            ((c & uLS) == uLS)
-        ) {
-            if (c == uCR) {
-                // check for CRLF
-                if (u == limit) {
-                    return -1; // LF may be in the next chunk
-                } else if (*u == uLF) {
-                    ++u; // include the LF in this chunk
-                }
-            }
-            return (int32_t)(u - s.getBuffer());
-        }
-    }
-
-    return -1; // continue collecting the chunk
-}
-
-enum {
-    CNV_NO_FEFF,    // cannot convert the U+FEFF Unicode signature character (BOM)
-    CNV_WITH_FEFF,  // can convert the U+FEFF signature character
-    CNV_ADDS_FEFF   // automatically adds/detects the U+FEFF signature character
-};
-
-static inline UChar
-nibbleToHex(uint8_t n) {
-    n &= 0xf;
-    return
-        n <= 9 ?
-            (UChar)(0x30 + n) :
-            (UChar)((0x61 - 10) + n);
-}
-
-// check the converter's Unicode signature properties;
-// the fromUnicode side of the converter must be in its initial state
-// and will be reset again if it was used
-static int32_t
-cnvSigType(UConverter *cnv) {
-    UErrorCode err;
-    int32_t result;
-
-    // test if the output charset can convert U+FEFF
-    USet *set = uset_open(1, 0);
-    err = U_ZERO_ERROR;
-    ucnv_getUnicodeSet(cnv, set, UCNV_ROUNDTRIP_SET, &err);
-    if (U_SUCCESS(err) && uset_contains(set, uSig)) {
-        result = CNV_WITH_FEFF;
-    } else {
-        result = CNV_NO_FEFF; // an error occurred or U+FEFF cannot be converted
-    }
-    uset_close(set);
-
-    if (result == CNV_WITH_FEFF) {
-        // test if the output charset emits a signature anyway
-        const UChar a[1] = { 0x61 }; // "a"
-        const UChar *in;
-
-        char buffer[20];
-        char *out;
-
-        in = a;
-        out = buffer;
-        err = U_ZERO_ERROR;
-        ucnv_fromUnicode(cnv,
-            &out, buffer + sizeof(buffer),
-            &in, a + 1,
-            NULL, TRUE, &err);
-        ucnv_resetFromUnicode(cnv);
-
-        if (NULL != ucnv_detectUnicodeSignature(buffer, (int32_t)(out - buffer), NULL, &err) &&
-            U_SUCCESS(err)
-        ) {
-            result = CNV_ADDS_FEFF;
-        }
-    }
-
-    return result;
-}
-
-class ConvertFile {
-public:
-    ConvertFile() :
-        buf(NULL), outbuf(NULL), fromoffsets(NULL),
-        bufsz(0), signature(0) {}
-
-    void
-    setBufferSize(size_t bufferSize) {
-        bufsz = bufferSize;
-
-        buf = new char[2 * bufsz];
-        outbuf = buf + bufsz;
-
-        // +1 for an added U+FEFF in the intermediate Unicode buffer
-        fromoffsets = new int32_t[bufsz + 1];
-    }
-
-    ~ConvertFile() {
-        delete [] buf;
-        delete [] fromoffsets;
-    }
-
-    UBool convertFile(const char *pname,
-                      const char *fromcpage,
-                      UConverterToUCallback toucallback,
-                      const void *touctxt,
-                      const char *tocpage,
-                      UConverterFromUCallback fromucallback,
-                      const void *fromuctxt,
-                      UBool fallback,
-                      const char *translit,
-                      const char *infilestr,
-                      FILE * outfile, int verbose);
-private:
-    friend int main(int argc, char **argv);
-
-    char *buf, *outbuf;
-    int32_t *fromoffsets;
-
-    size_t bufsz;
-    int8_t signature; // add (1) or remove (-1) a U+FEFF Unicode signature character
-};
-
-// Convert a file from one encoding to another
-UBool
-ConvertFile::convertFile(const char *pname,
-                         const char *fromcpage,
-                         UConverterToUCallback toucallback,
-                         const void *touctxt,
-                         const char *tocpage,
-                         UConverterFromUCallback fromucallback,
-                         const void *fromuctxt,
-                         UBool fallback,
-                         const char *translit,
-                         const char *infilestr,
-                         FILE * outfile, int verbose)
-{
-    FILE *infile;
-    UBool ret = TRUE;
-    UConverter *convfrom = 0;
-    UConverter *convto = 0;
-    UErrorCode err = U_ZERO_ERROR;
-    UBool flush;
-    const char *cbufp, *prevbufp;
-    char *bufp;
-
-    uint32_t infoffset = 0, outfoffset = 0;   /* Where we are in the file, for error reporting. */
-
-    const UChar *unibuf, *unibufbp;
-    UChar *unibufp;
-
-    size_t rd, wr;
-
-#if !UCONFIG_NO_TRANSLITERATION
-    Transliterator *t = 0;      // Transliterator acting on Unicode data.
-    UnicodeString chunk;        // One chunk of the text being collected for transformation.
-#endif
-    UnicodeString u;            // String to do the transliteration.
-    int32_t ulen;
-
-    // use conversion offsets for error messages
-    // unless a transliterator is used -
-    // a text transformation will reorder characters in unpredictable ways
-    UBool useOffsets = TRUE;
-
-    // Open the correct input file or connect to stdin for reading input
-
-    if (infilestr != 0 && strcmp(infilestr, "-")) {
-        infile = fopen(infilestr, "rb");
-        if (infile == 0) {
-            UnicodeString str1(infilestr, "");
-            str1.append((UChar32) 0);
-            UnicodeString str2(strerror(errno), "");
-            str2.append((UChar32) 0);
-            initMsg(pname);
-            u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer());
-            return FALSE;
-        }
-    } else {
-        infilestr = "-";
-        infile = stdin;
-#ifdef USE_FILENO_BINARY_MODE
-        if (setmode(fileno(stdin), O_BINARY) == -1) {
-            initMsg(pname);
-            u_wmsg(stderr, "cantSetInBinMode");
-            return FALSE;
-        }
-#endif
-    }
-
-    if (verbose) {
-        fprintf(stderr, "%s:\n", infilestr);
-    }
-
-#if !UCONFIG_NO_TRANSLITERATION
-    // Create transliterator as needed.
-
-    if (translit != NULL && *translit) {
-        UParseError parse;
-        UnicodeString str(translit), pestr;
-
-        /* Create from rules or by ID as needed. */
-
-        parse.line = -1;
-
-        if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') || uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
-            t = Transliterator::createFromRules("Uconv", str, UTRANS_FORWARD, parse, err);
-        } else {
-            t = Transliterator::createInstance(translit, UTRANS_FORWARD, err);
-        }
-
-        if (U_FAILURE(err)) {
-            str.append((UChar32) 0);
-            initMsg(pname);
-
-            if (parse.line >= 0) {
-                UChar linebuf[20], offsetbuf[20];
-                uprv_itou(linebuf, 20, parse.line, 10, 0);
-                uprv_itou(offsetbuf, 20, parse.offset, 10, 0);
-                u_wmsg(stderr, "cantCreateTranslitParseErr", str.getTerminatedBuffer(),
-                    u_wmsg_errorName(err), linebuf, offsetbuf);
-            } else {
-                u_wmsg(stderr, "cantCreateTranslit", str.getTerminatedBuffer(),
-                    u_wmsg_errorName(err));
-            }
-
-            if (t) {
-                delete t;
-                t = 0;
-            }
-            goto error_exit;
-        }
-
-        useOffsets = FALSE;
-    }
-#endif
-
-    // Create codepage converter. If the codepage or its aliases weren't
-    // available, it returns NULL and a failure code. We also set the
-    // callbacks, and return errors in the same way.
-
-    convfrom = ucnv_open(fromcpage, &err);
-    if (U_FAILURE(err)) {
-        UnicodeString str(fromcpage, "");
-        initMsg(pname);
-        u_wmsg(stderr, "cantOpenFromCodeset", str.getTerminatedBuffer(),
-            u_wmsg_errorName(err));
-        goto error_exit;
-    }
-    ucnv_setToUCallBack(convfrom, toucallback, touctxt, 0, 0, &err);
-    if (U_FAILURE(err)) {
-        initMsg(pname);
-        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));
-        goto error_exit;
-    }
-
-    convto = ucnv_open(tocpage, &err);
-    if (U_FAILURE(err)) {
-        UnicodeString str(tocpage, "");
-        initMsg(pname);
-        u_wmsg(stderr, "cantOpenToCodeset", str.getTerminatedBuffer(),
-            u_wmsg_errorName(err));
-        goto error_exit;
-    }
-    ucnv_setFromUCallBack(convto, fromucallback, fromuctxt, 0, 0, &err);
-    if (U_FAILURE(err)) {
-        initMsg(pname);
-        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));
-        goto error_exit;
-    }
-    ucnv_setFallback(convto, fallback);
-
-    UBool willexit, fromSawEndOfBytes, toSawEndOfUnicode;
-    int8_t sig;
-
-    // OK, we can convert now.
-    sig = signature;
-    rd = 0;
-
-    do {
-        willexit = FALSE;
-
-        // input file offset at the beginning of the next buffer
-        infoffset += rd;
-
-        rd = fread(buf, 1, bufsz, infile);
-        if (ferror(infile) != 0) {
-            UnicodeString str(strerror(errno));
-            initMsg(pname);
-            u_wmsg(stderr, "cantRead", str.getTerminatedBuffer());
-            goto error_exit;
-        }
-
-        // Convert the read buffer into the new encoding via Unicode.
-        // After the call 'unibufp' will be placed behind the last
-        // character that was converted in the 'unibuf'.
-        // Also the 'cbufp' is positioned behind the last converted
-        // character.
-        // At the last conversion in the file, flush should be set to
-        // true so that we get all characters converted.
-        //
-        // The converter must be flushed at the end of conversion so
-        // that characters on hold also will be written.
-
-        cbufp = buf;
-        flush = (UBool)(rd != bufsz);
-
-        // convert until the input is consumed
-        do {
-            // remember the start of the current byte-to-Unicode conversion
-            prevbufp = cbufp;
-
-            unibuf = unibufp = u.getBuffer((int32_t)bufsz);
-
-            // Use bufsz instead of u.getCapacity() for the targetLimit
-            // so that we don't overflow fromoffsets[].
-            ucnv_toUnicode(convfrom, &unibufp, unibuf + bufsz, &cbufp,
-                buf + rd, useOffsets ? fromoffsets : NULL, flush, &err);
-
-            ulen = (int32_t)(unibufp - unibuf);
-            u.releaseBuffer(U_SUCCESS(err) ? ulen : 0);
-
-            // fromSawEndOfBytes indicates that ucnv_toUnicode() is done
-            // converting all of the input bytes.
-            // It works like this because ucnv_toUnicode() returns only under the
-            // following conditions:
-            // - an error occurred during conversion (an error code is set)
-            // - the target buffer is filled (the error code indicates an overflow)
-            // - the source is consumed
-            // That is, if the error code does not indicate a failure,
-            // not even an overflow, then the source must be consumed entirely.
-            fromSawEndOfBytes = (UBool)U_SUCCESS(err);
-
-            if (err == U_BUFFER_OVERFLOW_ERROR) {
-                err = U_ZERO_ERROR;
-            } else if (U_FAILURE(err)) {
-                char pos[32], errorBytes[32];
-                int8_t i, length, errorLength;
-
-                UErrorCode localError = U_ZERO_ERROR;
-                errorLength = (int8_t)sizeof(errorBytes);
-                ucnv_getInvalidChars(convfrom, errorBytes, &errorLength, &localError);
-                if (U_FAILURE(localError) || errorLength == 0) {
-                    errorLength = 1;
-                }
-
-                // print the input file offset of the start of the error bytes:
-                // input file offset of the current byte buffer +
-                // length of the just consumed bytes -
-                // length of the error bytes
-                length =
-                    (int8_t)sprintf(pos, "%d",
-                        (int)(infoffset + (cbufp - buf) - errorLength));
-
-                // output the bytes that caused the error
-                UnicodeString str;
-                for (i = 0; i < errorLength; ++i) {
-                    if (i > 0) {
-                        str.append((UChar)uSP);
-                    }
-                    str.append(nibbleToHex((uint8_t)errorBytes[i] >> 4));
-                    str.append(nibbleToHex((uint8_t)errorBytes[i]));
-                }
-
-                initMsg(pname);
-                u_wmsg(stderr, "problemCvtToU",
-                        UnicodeString(pos, length, "").getTerminatedBuffer(),
-                        str.getTerminatedBuffer(),
-                        u_wmsg_errorName(err));
-
-                willexit = TRUE;
-                err = U_ZERO_ERROR; /* reset the error for the rest of the conversion. */
-            }
-
-            // Replaced a check for whether the input was consumed by
-            // looping until it is; message key "premEndInput" now obsolete.
-
-            if (ulen == 0) {
-                continue;
-            }
-
-            // remove a U+FEFF Unicode signature character if requested
-            if (sig < 0) {
-                if (u.charAt(0) == uSig) {
-                    u.remove(0, 1);
-
-                    // account for the removed UChar and offset
-                    --ulen;
-
-                    if (useOffsets) {
-                        // remove an offset from fromoffsets[] as well
-                        // to keep the array parallel with the UChars
-                        memmove(fromoffsets, fromoffsets + 1, ulen * 4);
-                    }
-
-                }
-                sig = 0;
-            }
-
-#if !UCONFIG_NO_TRANSLITERATION
-            // Transliterate/transform if needed.
-
-            // For transformation, we use chunking code -
-            // collect Unicode input until, for example, an end-of-line,
-            // then transform and output-convert that and continue collecting.
-            // This makes the transformation result independent of the buffer size
-            // while avoiding the slower keyboard mode.
-            // The end-of-chunk characters are completely included in the
-            // transformed string in case they are to be transformed themselves.
-            if (t != NULL) {
-                UnicodeString out;
-                int32_t chunkLimit;
-
-                do {
-                    chunkLimit = getChunkLimit(chunk, u);
-                    if (chunkLimit < 0 && flush && fromSawEndOfBytes) {
-                        // use all of the rest at the end of the text
-                        chunkLimit = u.length();
-                    }
-                    if (chunkLimit >= 0) {
-                        // complete the chunk and transform it
-                        chunk.append(u, 0, chunkLimit);
-                        u.remove(0, chunkLimit);
-                        t->transliterate(chunk);
-
-                        // append the transformation result to the result and empty the chunk
-                        out.append(chunk);
-                        chunk.remove();
-                    } else {
-                        // continue collecting the chunk
-                        chunk.append(u);
-                        break;
-                    }
-                } while (!u.isEmpty());
-
-                u = out;
-                ulen = u.length();
-            }
-#endif
-
-            // add a U+FEFF Unicode signature character if requested
-            // and possible/necessary
-            if (sig > 0) {
-                if (u.charAt(0) != uSig && cnvSigType(convto) == CNV_WITH_FEFF) {
-                    u.insert(0, (UChar)uSig);
-
-                    if (useOffsets) {
-                        // insert a pseudo-offset into fromoffsets[] as well
-                        // to keep the array parallel with the UChars
-                        memmove(fromoffsets + 1, fromoffsets, ulen * 4);
-                        fromoffsets[0] = -1;
-                    }
-
-                    // account for the additional UChar and offset
-                    ++ulen;
-                }
-                sig = 0;
-            }
-
-            // Convert the Unicode buffer into the destination codepage
-            // Again 'bufp' will be placed behind the last converted character
-            // And 'unibufp' will be placed behind the last converted unicode character
-            // At the last conversion flush should be set to true to ensure that
-            // all characters left get converted
-
-            unibuf = unibufbp = u.getBuffer();
-
-            do {
-                bufp = outbuf;
-
-                // Use fromSawEndOfBytes in addition to the flush flag -
-                // it indicates whether the intermediate Unicode string
-                // contains the very last UChars for the very last input bytes.
-                ucnv_fromUnicode(convto, &bufp, outbuf + bufsz,
-                                 &unibufbp,
-                                 unibuf + ulen,
-                                 NULL, (UBool)(flush && fromSawEndOfBytes), &err);
-
-                // toSawEndOfUnicode indicates that ucnv_fromUnicode() is done
-                // converting all of the intermediate UChars.
-                // See comment for fromSawEndOfBytes.
-                toSawEndOfUnicode = (UBool)U_SUCCESS(err);
-
-                if (err == U_BUFFER_OVERFLOW_ERROR) {
-                    err = U_ZERO_ERROR;
-                } else if (U_FAILURE(err)) {
-                    UChar errorUChars[4];
-                    const char *errtag;
-                    char pos[32];
-                    UChar32 c;
-                    int8_t i, length, errorLength;
-
-                    UErrorCode localError = U_ZERO_ERROR;
-                    errorLength = (int8_t)LENGTHOF(errorUChars);
-                    ucnv_getInvalidUChars(convto, errorUChars, &errorLength, &localError);
-                    if (U_FAILURE(localError) || errorLength == 0) {
-                        // need at least 1 so that we don't access beyond the length of fromoffsets[]
-                        errorLength = 1;
-                    }
-
-                    int32_t ferroffset;
-
-                    if (useOffsets) {
-                        // Unicode buffer offset of the start of the error UChars
-                        ferroffset = (int32_t)((unibufbp - unibuf) - errorLength);
-                        if (ferroffset < 0) {
-                            // approximation - the character started in the previous Unicode buffer
-                            ferroffset = 0;
-                        }
-
-                        // get the corresponding byte offset out of fromoffsets[]
-                        // go back if the offset is not known for some of the UChars
-                        int32_t fromoffset;
-                        do {
-                            fromoffset = fromoffsets[ferroffset];
-                        } while (fromoffset < 0 && --ferroffset >= 0);
-
-                        // total input file offset =
-                        // input file offset of the current byte buffer +
-                        // byte buffer offset of where the current Unicode buffer is converted from +
-                        // fromoffsets[Unicode offset]
-                        ferroffset = infoffset + (prevbufp - buf) + fromoffset;
-                        errtag = "problemCvtFromU";
-                    } else {
-                        // Do not use fromoffsets if (t != NULL) because the Unicode text may
-                        // be different from what the offsets refer to.
-
-                        // output file offset
-                        ferroffset = (int32_t)(outfoffset + (bufp - outbuf));
-                        errtag = "problemCvtFromUOut";
-                    }
-
-                    length = (int8_t)sprintf(pos, "%u", (int)ferroffset);
-
-                    // output the code points that caused the error
-                    UnicodeString str;
-                    for (i = 0; i < errorLength;) {
-                        if (i > 0) {
-                            str.append((UChar)uSP);
-                        }
-                        U16_NEXT(errorUChars, i, errorLength, c);
-                        if (c >= 0x100000) {
-                            str.append(nibbleToHex((uint8_t)(c >> 20)));
-                        }
-                        if (c >= 0x10000) {
-                            str.append(nibbleToHex((uint8_t)(c >> 16)));
-                        }
-                        str.append(nibbleToHex((uint8_t)(c >> 12)));
-                        str.append(nibbleToHex((uint8_t)(c >> 8)));
-                        str.append(nibbleToHex((uint8_t)(c >> 4)));
-                        str.append(nibbleToHex((uint8_t)c));
-                    }
-
-                    initMsg(pname);
-                    u_wmsg(stderr, errtag,
-                            UnicodeString(pos, length, "").getTerminatedBuffer(),
-                            str.getTerminatedBuffer(),
-                           u_wmsg_errorName(err));
-                    u_wmsg(stderr, "errorUnicode", str.getTerminatedBuffer());
-
-                    willexit = TRUE;
-                    err = U_ZERO_ERROR; /* reset the error for the rest of the conversion. */
-                }
-
-                // Replaced a check for whether the intermediate Unicode characters were all consumed by
-                // looping until they are; message key "premEnd" now obsolete.
-
-                // Finally, write the converted buffer to the output file
-                size_t outlen = (size_t) (bufp - outbuf);
-                outfoffset += (int32_t)(wr = fwrite(outbuf, 1, outlen, outfile));
-                if (wr != outlen) {
-                    UnicodeString str(strerror(errno));
-                    initMsg(pname);
-                    u_wmsg(stderr, "cantWrite", str.getTerminatedBuffer());
-                    willexit = TRUE;
-                }
-
-                if (willexit) {
-                    goto error_exit;
-                }
-            } while (!toSawEndOfUnicode);
-        } while (!fromSawEndOfBytes);
-    } while (!flush);           // Stop when we have flushed the
-                                // converters (this means that it's
-                                // the end of output)
-
-    goto normal_exit;
-
-error_exit:
-    ret = FALSE;
-
-normal_exit:
-    // Cleanup.
-
-    ucnv_close(convfrom);
-    ucnv_close(convto);
-
-#if !UCONFIG_NO_TRANSLITERATION
-    delete t;
-#endif
-
-    if (infile != stdin) {
-        fclose(infile);
-    }
-
-    return ret;
-}
-
-static void usage(const char *pname, int ecode) {
-    const UChar *msg;
-    int32_t msgLen;
-    UErrorCode err = U_ZERO_ERROR;
-    FILE *fp = ecode ? stderr : stdout;
-    int res;
-
-    initMsg(pname);
-    msg =
-        ures_getStringByKey(gBundle, ecode ? "lcUsageWord" : "ucUsageWord",
-                            &msgLen, &err);
-    UnicodeString upname(pname, (int32_t)(uprv_strlen(pname) + 1));
-    UnicodeString mname(msg, msgLen + 1);
-
-    res = u_wmsg(fp, "usage", mname.getBuffer(), upname.getBuffer());
-    if (!ecode) {
-        if (!res) {
-            fputc('\n', fp);
-        }
-        if (!u_wmsg(fp, "help")) {
-            /* Now dump callbacks and finish. */
-
-            int i, count =
-                sizeof(transcode_callbacks) / sizeof(*transcode_callbacks);
-            for (i = 0; i < count; ++i) {
-                fprintf(fp, " %s", transcode_callbacks[i].name);
-            }
-            fputc('\n', fp);
-        }
-    }
-
-    exit(ecode);
-}
-
-extern int
-main(int argc, char **argv)
-{
-    FILE *outfile;
-    int ret = 0;
-
-    size_t bufsz = DEFAULT_BUFSZ;
-
-    const char *fromcpage = 0;
-    const char *tocpage = 0;
-    const char *translit = 0;
-    const char *outfilestr = 0;
-    UBool fallback = FALSE;
-
-    UConverterFromUCallback fromucallback = UCNV_FROM_U_CALLBACK_STOP;
-    const void *fromuctxt = 0;
-    UConverterToUCallback toucallback = UCNV_TO_U_CALLBACK_STOP;
-    const void *touctxt = 0;
-
-    char **iter, **remainArgv, **remainArgvLimit;
-    char **end = argv + argc;
-
-    const char *pname;
-
-    UBool printConvs = FALSE, printCanon = FALSE, printTranslits = FALSE;
-    const char *printName = 0;
-
-    UBool verbose = FALSE;
-    UErrorCode status = U_ZERO_ERROR;
-
-    ConvertFile cf;
-
-    /* Initialize ICU */
-    u_init(&status);
-    if (U_FAILURE(status)) {
-        fprintf(stderr, "%s: can not initialize ICU.  status = %s\n",
-            argv[0], u_errorName(status));
-        exit(1);
-    }
-
-    // Get and prettify pname.
-    pname = uprv_strrchr(*argv, U_FILE_SEP_CHAR);
-#ifdef U_WINDOWS
-    if (!pname) {
-        pname = uprv_strrchr(*argv, '/');
-    }
-#endif
-    if (!pname) {
-        pname = *argv;
-    } else {
-        ++pname;
-    }
-
-    // First, get the arguments from command-line
-    // to know the codepages to convert between
-
-    remainArgv = remainArgvLimit = argv + 1;
-    for (iter = argv + 1; iter != end; iter++) {
-        // Check for from charset
-        if (strcmp("-f", *iter) == 0 || !strcmp("--from-code", *iter)) {
-            iter++;
-            if (iter != end)
-                fromcpage = *iter;
-            else
-                usage(pname, 1);
-        } else if (strcmp("-t", *iter) == 0 || !strcmp("--to-code", *iter)) {
-            iter++;
-            if (iter != end)
-                tocpage = *iter;
-            else
-                usage(pname, 1);
-        } else if (strcmp("-x", *iter) == 0) {
-            iter++;
-            if (iter != end)
-                translit = *iter;
-            else
-                usage(pname, 1);
-        } else if (!strcmp("--fallback", *iter)) {
-            fallback = TRUE;
-        } else if (!strcmp("--no-fallback", *iter)) {
-            fallback = FALSE;
-        } else if (strcmp("-b", *iter) == 0 || !strcmp("--block-size", *iter)) {
-            iter++;
-            if (iter != end) {
-                bufsz = atoi(*iter);
-                if ((int) bufsz <= 0) {
-                    initMsg(pname);
-                    UnicodeString str(*iter);
-                    initMsg(pname);
-                    u_wmsg(stderr, "badBlockSize", str.getTerminatedBuffer());
-                    return 3;
-                }
-            } else {
-                usage(pname, 1);
-            }
-        } else if (strcmp("-l", *iter) == 0 || !strcmp("--list", *iter)) {
-            if (printTranslits) {
-                usage(pname, 1);
-            }
-            printConvs = TRUE;
-        } else if (strcmp("--default-code", *iter) == 0) {
-            if (printTranslits) {
-                usage(pname, 1);
-            }
-            printName = ucnv_getDefaultName();
-        } else if (strcmp("--list-code", *iter) == 0) {
-            if (printTranslits) {
-                usage(pname, 1);
-            }
-
-            iter++;
-            if (iter != end) {
-                UErrorCode e = U_ZERO_ERROR;
-                printName = ucnv_getAlias(*iter, 0, &e);
-                if (U_FAILURE(e) || !printName) {
-                    UnicodeString str(*iter);
-                    initMsg(pname);
-                    u_wmsg(stderr, "noSuchCodeset", str.getTerminatedBuffer());
-                    return 2;
-                }
-            } else
-                usage(pname, 1);
-        } else if (strcmp("--canon", *iter) == 0) {
-            printCanon = TRUE;
-        } else if (strcmp("-L", *iter) == 0
-            || !strcmp("--list-transliterators", *iter)) {
-            if (printConvs) {
-                usage(pname, 1);
-            }
-            printTranslits = TRUE;
-        } else if (strcmp("-h", *iter) == 0 || !strcmp("-?", *iter)
-            || !strcmp("--help", *iter)) {
-            usage(pname, 0);
-        } else if (!strcmp("-c", *iter)) {
-            fromucallback = UCNV_FROM_U_CALLBACK_SKIP;
-        } else if (!strcmp("--to-callback", *iter)) {
-            iter++;
-            if (iter != end) {
-                const struct callback_ent *cbe = findCallback(*iter);
-                if (cbe) {
-                    fromucallback = cbe->fromu;
-                    fromuctxt = cbe->fromuctxt;
-                } else {
-                    UnicodeString str(*iter);
-                    initMsg(pname);
-                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
-                    return 4;
-                }
-            } else {
-                usage(pname, 1);
-            }
-        } else if (!strcmp("--from-callback", *iter)) {
-            iter++;
-            if (iter != end) {
-                const struct callback_ent *cbe = findCallback(*iter);
-                if (cbe) {
-                    toucallback = cbe->tou;
-                    touctxt = cbe->touctxt;
-                } else {
-                    UnicodeString str(*iter);
-                    initMsg(pname);
-                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
-                    return 4;
-                }
-            } else {
-                usage(pname, 1);
-            }
-        } else if (!strcmp("-i", *iter)) {
-            toucallback = UCNV_TO_U_CALLBACK_SKIP;
-        } else if (!strcmp("--callback", *iter)) {
-            iter++;
-            if (iter != end) {
-                const struct callback_ent *cbe = findCallback(*iter);
-                if (cbe) {
-                    fromucallback = cbe->fromu;
-                    fromuctxt = cbe->fromuctxt;
-                    toucallback = cbe->tou;
-                    touctxt = cbe->touctxt;
-                } else {
-                    UnicodeString str(*iter);
-                    initMsg(pname);
-                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
-                    return 4;
-                }
-            } else {
-                usage(pname, 1);
-            }
-        } else if (!strcmp("-s", *iter) || !strcmp("--silent", *iter)) {
-            verbose = FALSE;
-        } else if (!strcmp("-v", *iter) || !strcmp("--verbose", *iter)) {
-            verbose = TRUE;
-        } else if (!strcmp("-V", *iter) || !strcmp("--version", *iter)) {
-            printf("%s v2.1  ICU " U_ICU_VERSION "\n", pname);
-            return 0;
-        } else if (!strcmp("-o", *iter) || !strcmp("--output", *iter)) {
-            ++iter;
-            if (iter != end && !outfilestr) {
-                outfilestr = *iter;
-            } else {
-                usage(pname, 1);
-            }
-        } else if (0 == strcmp("--add-signature", *iter)) {
-            cf.signature = 1;
-        } else if (0 == strcmp("--remove-signature", *iter)) {
-            cf.signature = -1;
-        } else if (**iter == '-' && (*iter)[1]) {
-            usage(pname, 1);
-        } else {
-            // move a non-option up in argv[]
-            *remainArgvLimit++ = *iter;
-        }
-    }
-
-    if (printConvs || printName) {
-        return printConverters(pname, printName, printCanon) ? 2 : 0;
-    } else if (printTranslits) {
-        return printTransliterators(printCanon) ? 3 : 0;
-    }
-
-    if (!fromcpage || !uprv_strcmp(fromcpage, "-")) {
-        fromcpage = ucnv_getDefaultName();
-    }
-    if (!tocpage || !uprv_strcmp(tocpage, "-")) {
-        tocpage = ucnv_getDefaultName();
-    }
-
-    // Open the correct output file or connect to stdout for reading input
-    if (outfilestr != 0 && strcmp(outfilestr, "-")) {
-        outfile = fopen(outfilestr, "wb");
-        if (outfile == 0) {
-            UnicodeString str1(outfilestr, "");
-            UnicodeString str2(strerror(errno), "");
-            initMsg(pname);
-            u_wmsg(stderr, "cantCreateOutputF",
-                str1.getBuffer(), str2.getBuffer());
-            return 1;
-        }
-    } else {
-        outfilestr = "-";
-        outfile = stdout;
-#ifdef USE_FILENO_BINARY_MODE
-        if (setmode(fileno(outfile), O_BINARY) == -1) {
-            u_wmsg(stderr, "cantSetOutBinMode");
-            exit(-1);
-        }
-#endif
-    }
-
-    /* Loop again on the arguments to find all the input files, and
-    convert them. */
-
-    cf.setBufferSize(bufsz);
-
-    if(remainArgv < remainArgvLimit) {
-        for (iter = remainArgv; iter != remainArgvLimit; iter++) {
-            if (!cf.convertFile(
-                    pname, fromcpage, toucallback, touctxt, tocpage,
-                    fromucallback, fromuctxt, fallback, translit, *iter,
-                    outfile, verbose)
-            ) {
-                goto error_exit;
-            }
-        }
-    } else {
-        if (!cf.convertFile(
-                pname, fromcpage, toucallback, touctxt, tocpage,
-                fromucallback, fromuctxt, fallback, translit, 0,
-                outfile, verbose)
-        ) {
-            goto error_exit;
-        }
-    }
-
-    goto normal_exit;
-error_exit:
-    ret = 1;
-normal_exit:
-
-    if (outfile != stdout) {
-        fclose(outfile);
-    }
-
-    return ret;
-}
-
-
-/*
- * Hey, Emacs, please set the following:
- *
- * Local Variables:
- * indent-tabs-mode: nil
- * End:
- *
- */
+/*****************************************************************************
+*
+*   Copyright (C) 1999-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************/
+
+/*
+ * uconv(1): an iconv(1)-like converter using ICU.
+ *
+ * Original code by Jonas Utterstr&#x00F6;m <jonas.utterstrom at vittran.norrnod.se>
+ * contributed in 1999.
+ *
+ * Conversion to the C conversion API and many improvements by
+ * Yves Arrouye <yves at realnames.com>, current maintainer.
+ *
+ * Markus Scherer maintainer from 2003.
+ * See source code repository history for changes.
+ */
+
+#include <unicode/utypes.h>
+#include <unicode/putil.h>
+#include <unicode/ucnv.h>
+#include <unicode/uenum.h>
+#include <unicode/unistr.h>
+#include <unicode/translit.h>
+#include <unicode/uset.h>
+#include <unicode/uclean.h>
+
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "cmemory.h"
+#include "cstring.h"
+#include "ustrfmt.h"
+
+#include "unicode/uwmsg.h"
+
+#if (defined(U_WINDOWS) || defined(U_CYGWIN)) && !defined(__STRICT_ANSI__)
+#include <io.h>
+#include <fcntl.h>
+#if defined(U_WINDOWS)
+#define USE_FILENO_BINARY_MODE 1
+/* Windows likes to rename Unix-like functions */
+#ifndef fileno
+#define fileno _fileno
+#endif
+#ifndef setmode
+#define setmode _setmode
+#endif
+#ifndef O_BINARY
+#define O_BINARY _O_BINARY
+#endif
+#endif
+#endif
+
+#ifdef UCONVMSG_LINK
+/* below from the README */
+#include "unicode/utypes.h"
+#include "unicode/udata.h"
+U_CFUNC char uconvmsg_dat[];
+#endif
+
+#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
+
+#define DEFAULT_BUFSZ   4096
+#define UCONVMSG "uconvmsg"
+
+static UResourceBundle *gBundle = 0;    /* Bundle containing messages. */
+
+/*
+ * Initialize the message bundle so that message strings can be fetched
+ * by u_wmsg().
+ *
+ */
+
+static void initMsg(const char *pname) {
+    static int ps = 0;
+
+    if (!ps) {
+        char dataPath[2048];        /* XXX Sloppy: should be PATH_MAX. */
+        UErrorCode err = U_ZERO_ERROR;
+
+        ps = 1;
+
+        /* Set up our static data - if any */
+#ifdef UCONVMSG_LINK
+        udata_setAppData(UCONVMSG, (const void*) uconvmsg_dat, &err);
+        if (U_FAILURE(err)) {
+          fprintf(stderr, "%s: warning, problem installing our static resource bundle data uconvmsg: %s - trying anyways.\n",
+                  pname, u_errorName(err));
+          err = U_ZERO_ERROR; /* It may still fail */
+        }
+#endif
+
+        /* Get messages. */
+        gBundle = u_wmsg_setPath(UCONVMSG, &err);
+        if (U_FAILURE(err)) {
+            fprintf(stderr,
+                    "%s: warning: couldn't open bundle %s: %s\n",
+                    pname, UCONVMSG, u_errorName(err));
+#ifdef UCONVMSG_LINK
+            fprintf(stderr,
+                    "%s: setAppData was called, internal data %s failed to load\n",
+                        pname, UCONVMSG);
+#endif
+ 
+            err = U_ZERO_ERROR;
+            /* that was try #1, try again with a path */
+            uprv_strcpy(dataPath, u_getDataDirectory());
+            uprv_strcat(dataPath, U_FILE_SEP_STRING);
+            uprv_strcat(dataPath, UCONVMSG);
+
+            gBundle = u_wmsg_setPath(dataPath, &err);
+            if (U_FAILURE(err)) {
+                fprintf(stderr,
+                    "%s: warning: still couldn't open bundle %s: %s\n",
+                    pname, dataPath, u_errorName(err));
+                fprintf(stderr, "%s: warning: messages will not be displayed\n", pname);
+            }
+        }
+    }
+}
+
+/* Mapping of callback names to the callbacks passed to the converter
+   API. */
+
+static struct callback_ent {
+    const char *name;
+    UConverterFromUCallback fromu;
+    const void *fromuctxt;
+    UConverterToUCallback tou;
+    const void *touctxt;
+} transcode_callbacks[] = {
+    { "substitute",
+      UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0,
+      UCNV_TO_U_CALLBACK_SUBSTITUTE, 0 },
+    { "skip",
+      UCNV_FROM_U_CALLBACK_SKIP, 0,
+      UCNV_TO_U_CALLBACK_SKIP, 0 },
+    { "stop",
+      UCNV_FROM_U_CALLBACK_STOP, 0,
+      UCNV_TO_U_CALLBACK_STOP, 0 },
+    { "escape",
+      UCNV_FROM_U_CALLBACK_ESCAPE, 0,
+      UCNV_TO_U_CALLBACK_ESCAPE, 0},
+    { "escape-icu",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_ICU,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_ICU },
+    { "escape-java",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_JAVA,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_JAVA },
+    { "escape-c",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_C },
+    { "escape-xml",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX },
+    { "escape-xml-hex",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_HEX },
+    { "escape-xml-dec",
+      UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC },
+    { "escape-unicode", UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_UNICODE,
+      UCNV_TO_U_CALLBACK_ESCAPE, UCNV_ESCAPE_UNICODE }
+};
+
+/* Return a pointer to a callback record given its name. */
+
+static const struct callback_ent *findCallback(const char *name) {
+    int i, count =
+        sizeof(transcode_callbacks) / sizeof(*transcode_callbacks);
+
+    /* We'll do a linear search, there aren't many of them and bsearch()
+       may not be that portable. */
+
+    for (i = 0; i < count; ++i) {
+        if (!uprv_stricmp(name, transcode_callbacks[i].name)) {
+            return &transcode_callbacks[i];
+        }
+    }
+
+    return 0;
+}
+
+/* Print converter information. If lookfor is set, only that converter will
+   be printed, otherwise all converters will be printed. If canon is non
+   zero, tags and aliases for each converter are printed too, in the format
+   expected for convrters.txt(5). */
+
+static int printConverters(const char *pname, const char *lookfor,
+    UBool canon)
+{
+    UErrorCode err = U_ZERO_ERROR;
+    int32_t num;
+    uint16_t num_stds;
+    const char **stds;
+
+    /* If there is a specified name, just handle that now. */
+
+    if (lookfor) {
+        if (!canon) {
+            printf("%s\n", lookfor);
+            return 0;
+        } else {
+        /*  Because we are printing a canonical name, we need the
+            true converter name. We've done that already except for
+            the default name (because we want to print the exact
+            name one would get when calling ucnv_getDefaultName()
+            in non-canon mode). But since we do not know at this
+            point if we have the default name or something else, we
+            need to normalize again to the canonical converter
+            name. */
+
+            const char *truename = ucnv_getAlias(lookfor, 0, &err);
+            if (U_SUCCESS(err)) {
+                lookfor = truename;
+            } else {
+                err = U_ZERO_ERROR;
+            }
+        }
+    }
+
+    /* Print converter names. We come here for one of two reasons: we
+       are printing all the names (lookfor was null), or we have a
+       single converter to print but in canon mode, hence we need to
+       get to it in order to print everything. */
+
+    num = ucnv_countAvailable();
+    if (num <= 0) {
+        initMsg(pname);
+        u_wmsg(stderr, "cantGetNames");
+        return -1;
+    }
+    if (lookfor) {
+        num = 1;                /* We know where we want to be. */
+    }
+
+    num_stds = ucnv_countStandards();
+    stds = (const char **) uprv_malloc(num_stds * sizeof(*stds));
+    if (!stds) {
+        u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(U_MEMORY_ALLOCATION_ERROR));
+        return -1;
+    } else {
+        uint16_t s;
+
+        if (canon) {
+            printf("{ ");
+        }
+        for (s = 0; s < num_stds; ++s) {
+            stds[s] = ucnv_getStandard(s, &err);
+            if (canon) {
+                printf("%s ", stds[s]);
+            }
+            if (U_FAILURE(err)) {
+                u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(err));
+                return -1;
+            }
+        }
+        if (canon) {
+            puts("}");
+        }
+    }
+
+    for (int32_t i = 0; i < num; i++) {
+        const char *name;
+        uint16_t num_aliases;
+
+        /* Set the name either to what we are looking for, or
+        to the current converter name. */
+
+        if (lookfor) {
+            name = lookfor;
+        } else {
+            name = ucnv_getAvailableName(i);
+        }
+
+        /* Get all the aliases associated to the name. */
+
+        err = U_ZERO_ERROR;
+        num_aliases = ucnv_countAliases(name, &err);
+        if (U_FAILURE(err)) {
+            printf("%s", name);
+
+            UnicodeString str(name, "");
+            putchar('\t');
+            u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
+                u_wmsg_errorName(err));
+            return -1;
+        } else {
+            uint16_t a, s, t;
+
+            /* Write all the aliases and their tags. */
+
+            for (a = 0; a < num_aliases; ++a) {
+                const char *alias = ucnv_getAlias(name, a, &err);
+
+                if (U_FAILURE(err)) {
+                    UnicodeString str(name, "");
+                    putchar('\t');
+                    u_wmsg(stderr, "cantGetAliases", str.getTerminatedBuffer(),
+                        u_wmsg_errorName(err));
+                    return -1;
+                }
+
+                /* Print the current alias so that it looks right. */
+                printf("%s%s%s", (canon ? (a == 0? "" : "\t" ) : "") ,
+                                 alias,
+                                 (canon ? "" : " "));
+
+                /* Look (slowly, linear searching) for a tag. */
+
+                if (canon) {
+                    /* -1 to skip the last standard */
+                    for (s = t = 0; s < num_stds-1; ++s) {
+                        UEnumeration *nameEnum = ucnv_openStandardNames(name, stds[s], &err);
+                        if (U_SUCCESS(err)) {
+                            /* List the standard tags */
+                            const char *standardName;
+                            UBool isFirst = TRUE;
+                            UErrorCode enumError = U_ZERO_ERROR;
+                            while ((standardName = uenum_next(nameEnum, NULL, &enumError))) {
+                                /* See if this alias is supported by this standard. */
+                                if (!strcmp(standardName, alias)) {
+                                    if (!t) {
+                                        printf(" {");
+                                        t = 1;
+                                    }
+                                    /* Print a * after the default standard name */
+                                    printf(" %s%s", stds[s], (isFirst ? "*" : ""));
+                                }
+                                isFirst = FALSE;
+                            }
+                        }
+                    }
+                    if (t) {
+                        printf(" }");
+                    }
+                }
+                /* Terminate this entry. */
+                if (canon) {
+                    puts("");
+                }
+
+                /* Move on. */
+            }
+            /* Terminate this entry. */
+            if (!canon) {
+                puts("");
+            }
+        }
+    }
+
+    /* Free temporary data. */
+
+    uprv_free(stds);
+
+    /* Success. */
+
+    return 0;
+}
+
+/* Print all available transliterators. If canon is non zero, print
+   one transliterator per line. */
+
+static int printTransliterators(UBool canon)
+{
+#if UCONFIG_NO_TRANSLITERATION
+    printf("no transliterators available because of UCONFIG_NO_TRANSLITERATION, see uconfig.h\n");
+    return 1;
+#else
+    int32_t numtrans = utrans_countAvailableIDs(), i;
+    int buflen = 512;
+    char *buf = (char *) uprv_malloc(buflen);
+    char staticbuf[512];
+
+    char sepchar = canon ? '\n' : ' ';
+
+    if (!buf) {
+        buf = staticbuf;
+        buflen = sizeof(staticbuf);
+    }
+
+    for (i = 0; i < numtrans; ++i) {
+        int32_t len = utrans_getAvailableID(i, buf, buflen);
+        if (len >= buflen - 1) {
+            if (buf != staticbuf) {
+                buflen <<= 1;
+                if (buflen < len) {
+                    buflen = len + 64;
+                }
+                buf = (char *) uprv_realloc(buf, buflen);
+                if (!buf) {
+                    buf = staticbuf;
+                    buflen = sizeof(staticbuf);
+                }
+            }
+            utrans_getAvailableID(i, buf, buflen);
+            if (len >= buflen) {
+                uprv_strcpy(buf + buflen - 4, "..."); /* Truncate the name. */
+            }
+        }
+
+        printf("%s", buf);
+        if (i < numtrans - 1) {
+            putchar(sepchar);
+        }
+    }
+
+    /* Add a terminating newline if needed. */
+
+    if (sepchar != '\n') {
+        putchar('\n');
+    }
+
+    /* Free temporary data. */
+
+    if (buf != staticbuf) {
+        uprv_free(buf);
+    }
+
+    /* Success. */
+
+    return 0;
+#endif
+}
+
+enum {
+    uSP = 0x20,         // space
+    uCR = 0xd,          // carriage return
+    uLF = 0xa,          // line feed
+    uNL = 0x85,         // newline
+    uLS = 0x2028,       // line separator
+    uPS = 0x2029,       // paragraph separator
+    uSig = 0xfeff       // signature/BOM character
+};
+
+static inline int32_t
+getChunkLimit(const UnicodeString &prev, const UnicodeString &s) {
+    // find one of
+    // CR, LF, CRLF, NL, LS, PS
+    // for paragraph ends (see UAX #13/Unicode 4)
+    // and include it in the chunk
+    // all of these characters are on the BMP
+    // do not include FF or VT in case they are part of a paragraph
+    // (important for bidi contexts)
+    static const UChar paraEnds[] = {
+        0xd, 0xa, 0x85, 0x2028, 0x2029
+    };
+    enum {
+        iCR, iLF, iNL, iLS, iPS, iCount
+    };
+
+    // first, see if there is a CRLF split between prev and s
+    if (prev.endsWith(paraEnds + iCR, 1)) {
+        if (s.startsWith(paraEnds + iLF, 1)) {
+            return 1; // split CRLF, include the LF
+        } else if (!s.isEmpty()) {
+            return 0; // complete the last chunk
+        } else {
+            return -1; // wait for actual further contents to arrive
+        }
+    }
+
+    const UChar *u = s.getBuffer(), *limit = u + s.length();
+    UChar c;
+
+    while (u < limit) {
+        c = *u++;
+        if (
+            ((c < uSP) && (c == uCR || c == uLF)) ||
+            (c == uNL) ||
+            ((c & uLS) == uLS)
+        ) {
+            if (c == uCR) {
+                // check for CRLF
+                if (u == limit) {
+                    return -1; // LF may be in the next chunk
+                } else if (*u == uLF) {
+                    ++u; // include the LF in this chunk
+                }
+            }
+            return (int32_t)(u - s.getBuffer());
+        }
+    }
+
+    return -1; // continue collecting the chunk
+}
+
+enum {
+    CNV_NO_FEFF,    // cannot convert the U+FEFF Unicode signature character (BOM)
+    CNV_WITH_FEFF,  // can convert the U+FEFF signature character
+    CNV_ADDS_FEFF   // automatically adds/detects the U+FEFF signature character
+};
+
+static inline UChar
+nibbleToHex(uint8_t n) {
+    n &= 0xf;
+    return
+        n <= 9 ?
+            (UChar)(0x30 + n) :
+            (UChar)((0x61 - 10) + n);
+}
+
+// check the converter's Unicode signature properties;
+// the fromUnicode side of the converter must be in its initial state
+// and will be reset again if it was used
+static int32_t
+cnvSigType(UConverter *cnv) {
+    UErrorCode err;
+    int32_t result;
+
+    // test if the output charset can convert U+FEFF
+    USet *set = uset_open(1, 0);
+    err = U_ZERO_ERROR;
+    ucnv_getUnicodeSet(cnv, set, UCNV_ROUNDTRIP_SET, &err);
+    if (U_SUCCESS(err) && uset_contains(set, uSig)) {
+        result = CNV_WITH_FEFF;
+    } else {
+        result = CNV_NO_FEFF; // an error occurred or U+FEFF cannot be converted
+    }
+    uset_close(set);
+
+    if (result == CNV_WITH_FEFF) {
+        // test if the output charset emits a signature anyway
+        const UChar a[1] = { 0x61 }; // "a"
+        const UChar *in;
+
+        char buffer[20];
+        char *out;
+
+        in = a;
+        out = buffer;
+        err = U_ZERO_ERROR;
+        ucnv_fromUnicode(cnv,
+            &out, buffer + sizeof(buffer),
+            &in, a + 1,
+            NULL, TRUE, &err);
+        ucnv_resetFromUnicode(cnv);
+
+        if (NULL != ucnv_detectUnicodeSignature(buffer, (int32_t)(out - buffer), NULL, &err) &&
+            U_SUCCESS(err)
+        ) {
+            result = CNV_ADDS_FEFF;
+        }
+    }
+
+    return result;
+}
+
+class ConvertFile {
+public:
+    ConvertFile() :
+        buf(NULL), outbuf(NULL), fromoffsets(NULL),
+        bufsz(0), signature(0) {}
+
+    void
+    setBufferSize(size_t bufferSize) {
+        bufsz = bufferSize;
+
+        buf = new char[2 * bufsz];
+        outbuf = buf + bufsz;
+
+        // +1 for an added U+FEFF in the intermediate Unicode buffer
+        fromoffsets = new int32_t[bufsz + 1];
+    }
+
+    ~ConvertFile() {
+        delete [] buf;
+        delete [] fromoffsets;
+    }
+
+    UBool convertFile(const char *pname,
+                      const char *fromcpage,
+                      UConverterToUCallback toucallback,
+                      const void *touctxt,
+                      const char *tocpage,
+                      UConverterFromUCallback fromucallback,
+                      const void *fromuctxt,
+                      UBool fallback,
+                      const char *translit,
+                      const char *infilestr,
+                      FILE * outfile, int verbose);
+private:
+    friend int main(int argc, char **argv);
+
+    char *buf, *outbuf;
+    int32_t *fromoffsets;
+
+    size_t bufsz;
+    int8_t signature; // add (1) or remove (-1) a U+FEFF Unicode signature character
+};
+
+// Convert a file from one encoding to another
+UBool
+ConvertFile::convertFile(const char *pname,
+                         const char *fromcpage,
+                         UConverterToUCallback toucallback,
+                         const void *touctxt,
+                         const char *tocpage,
+                         UConverterFromUCallback fromucallback,
+                         const void *fromuctxt,
+                         UBool fallback,
+                         const char *translit,
+                         const char *infilestr,
+                         FILE * outfile, int verbose)
+{
+    FILE *infile;
+    UBool ret = TRUE;
+    UConverter *convfrom = 0;
+    UConverter *convto = 0;
+    UErrorCode err = U_ZERO_ERROR;
+    UBool flush;
+    const char *cbufp, *prevbufp;
+    char *bufp;
+
+    uint32_t infoffset = 0, outfoffset = 0;   /* Where we are in the file, for error reporting. */
+
+    const UChar *unibuf, *unibufbp;
+    UChar *unibufp;
+
+    size_t rd, wr;
+
+#if !UCONFIG_NO_TRANSLITERATION
+    Transliterator *t = 0;      // Transliterator acting on Unicode data.
+    UnicodeString chunk;        // One chunk of the text being collected for transformation.
+#endif
+    UnicodeString u;            // String to do the transliteration.
+    int32_t ulen;
+
+    // use conversion offsets for error messages
+    // unless a transliterator is used -
+    // a text transformation will reorder characters in unpredictable ways
+    UBool useOffsets = TRUE;
+
+    // Open the correct input file or connect to stdin for reading input
+
+    if (infilestr != 0 && strcmp(infilestr, "-")) {
+        infile = fopen(infilestr, "rb");
+        if (infile == 0) {
+            UnicodeString str1(infilestr, "");
+            str1.append((UChar32) 0);
+            UnicodeString str2(strerror(errno), "");
+            str2.append((UChar32) 0);
+            initMsg(pname);
+            u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer());
+            return FALSE;
+        }
+    } else {
+        infilestr = "-";
+        infile = stdin;
+#ifdef USE_FILENO_BINARY_MODE
+        if (setmode(fileno(stdin), O_BINARY) == -1) {
+            initMsg(pname);
+            u_wmsg(stderr, "cantSetInBinMode");
+            return FALSE;
+        }
+#endif
+    }
+
+    if (verbose) {
+        fprintf(stderr, "%s:\n", infilestr);
+    }
+
+#if !UCONFIG_NO_TRANSLITERATION
+    // Create transliterator as needed.
+
+    if (translit != NULL && *translit) {
+        UParseError parse;
+        UnicodeString str(translit), pestr;
+
+        /* Create from rules or by ID as needed. */
+
+        parse.line = -1;
+
+        if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') || uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
+            t = Transliterator::createFromRules("Uconv", str, UTRANS_FORWARD, parse, err);
+        } else {
+            t = Transliterator::createInstance(translit, UTRANS_FORWARD, err);
+        }
+
+        if (U_FAILURE(err)) {
+            str.append((UChar32) 0);
+            initMsg(pname);
+
+            if (parse.line >= 0) {
+                UChar linebuf[20], offsetbuf[20];
+                uprv_itou(linebuf, 20, parse.line, 10, 0);
+                uprv_itou(offsetbuf, 20, parse.offset, 10, 0);
+                u_wmsg(stderr, "cantCreateTranslitParseErr", str.getTerminatedBuffer(),
+                    u_wmsg_errorName(err), linebuf, offsetbuf);
+            } else {
+                u_wmsg(stderr, "cantCreateTranslit", str.getTerminatedBuffer(),
+                    u_wmsg_errorName(err));
+            }
+
+            if (t) {
+                delete t;
+                t = 0;
+            }
+            goto error_exit;
+        }
+
+        useOffsets = FALSE;
+    }
+#endif
+
+    // Create codepage converter. If the codepage or its aliases weren't
+    // available, it returns NULL and a failure code. We also set the
+    // callbacks, and return errors in the same way.
+
+    convfrom = ucnv_open(fromcpage, &err);
+    if (U_FAILURE(err)) {
+        UnicodeString str(fromcpage, "");
+        initMsg(pname);
+        u_wmsg(stderr, "cantOpenFromCodeset", str.getTerminatedBuffer(),
+            u_wmsg_errorName(err));
+        goto error_exit;
+    }
+    ucnv_setToUCallBack(convfrom, toucallback, touctxt, 0, 0, &err);
+    if (U_FAILURE(err)) {
+        initMsg(pname);
+        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));
+        goto error_exit;
+    }
+
+    convto = ucnv_open(tocpage, &err);
+    if (U_FAILURE(err)) {
+        UnicodeString str(tocpage, "");
+        initMsg(pname);
+        u_wmsg(stderr, "cantOpenToCodeset", str.getTerminatedBuffer(),
+            u_wmsg_errorName(err));
+        goto error_exit;
+    }
+    ucnv_setFromUCallBack(convto, fromucallback, fromuctxt, 0, 0, &err);
+    if (U_FAILURE(err)) {
+        initMsg(pname);
+        u_wmsg(stderr, "cantSetCallback", u_wmsg_errorName(err));
+        goto error_exit;
+    }
+    ucnv_setFallback(convto, fallback);
+
+    UBool willexit, fromSawEndOfBytes, toSawEndOfUnicode;
+    int8_t sig;
+
+    // OK, we can convert now.
+    sig = signature;
+    rd = 0;
+
+    do {
+        willexit = FALSE;
+
+        // input file offset at the beginning of the next buffer
+        infoffset += rd;
+
+        rd = fread(buf, 1, bufsz, infile);
+        if (ferror(infile) != 0) {
+            UnicodeString str(strerror(errno));
+            initMsg(pname);
+            u_wmsg(stderr, "cantRead", str.getTerminatedBuffer());
+            goto error_exit;
+        }
+
+        // Convert the read buffer into the new encoding via Unicode.
+        // After the call 'unibufp' will be placed behind the last
+        // character that was converted in the 'unibuf'.
+        // Also the 'cbufp' is positioned behind the last converted
+        // character.
+        // At the last conversion in the file, flush should be set to
+        // true so that we get all characters converted.
+        //
+        // The converter must be flushed at the end of conversion so
+        // that characters on hold also will be written.
+
+        cbufp = buf;
+        flush = (UBool)(rd != bufsz);
+
+        // convert until the input is consumed
+        do {
+            // remember the start of the current byte-to-Unicode conversion
+            prevbufp = cbufp;
+
+            unibuf = unibufp = u.getBuffer((int32_t)bufsz);
+
+            // Use bufsz instead of u.getCapacity() for the targetLimit
+            // so that we don't overflow fromoffsets[].
+            ucnv_toUnicode(convfrom, &unibufp, unibuf + bufsz, &cbufp,
+                buf + rd, useOffsets ? fromoffsets : NULL, flush, &err);
+
+            ulen = (int32_t)(unibufp - unibuf);
+            u.releaseBuffer(U_SUCCESS(err) ? ulen : 0);
+
+            // fromSawEndOfBytes indicates that ucnv_toUnicode() is done
+            // converting all of the input bytes.
+            // It works like this because ucnv_toUnicode() returns only under the
+            // following conditions:
+            // - an error occurred during conversion (an error code is set)
+            // - the target buffer is filled (the error code indicates an overflow)
+            // - the source is consumed
+            // That is, if the error code does not indicate a failure,
+            // not even an overflow, then the source must be consumed entirely.
+            fromSawEndOfBytes = (UBool)U_SUCCESS(err);
+
+            if (err == U_BUFFER_OVERFLOW_ERROR) {
+                err = U_ZERO_ERROR;
+            } else if (U_FAILURE(err)) {
+                char pos[32], errorBytes[32];
+                int8_t i, length, errorLength;
+
+                UErrorCode localError = U_ZERO_ERROR;
+                errorLength = (int8_t)sizeof(errorBytes);
+                ucnv_getInvalidChars(convfrom, errorBytes, &errorLength, &localError);
+                if (U_FAILURE(localError) || errorLength == 0) {
+                    errorLength = 1;
+                }
+
+                // print the input file offset of the start of the error bytes:
+                // input file offset of the current byte buffer +
+                // length of the just consumed bytes -
+                // length of the error bytes
+                length =
+                    (int8_t)sprintf(pos, "%d",
+                        (int)(infoffset + (cbufp - buf) - errorLength));
+
+                // output the bytes that caused the error
+                UnicodeString str;
+                for (i = 0; i < errorLength; ++i) {
+                    if (i > 0) {
+                        str.append((UChar)uSP);
+                    }
+                    str.append(nibbleToHex((uint8_t)errorBytes[i] >> 4));
+                    str.append(nibbleToHex((uint8_t)errorBytes[i]));
+                }
+
+                initMsg(pname);
+                u_wmsg(stderr, "problemCvtToU",
+                        UnicodeString(pos, length, "").getTerminatedBuffer(),
+                        str.getTerminatedBuffer(),
+                        u_wmsg_errorName(err));
+
+                willexit = TRUE;
+                err = U_ZERO_ERROR; /* reset the error for the rest of the conversion. */
+            }
+
+            // Replaced a check for whether the input was consumed by
+            // looping until it is; message key "premEndInput" now obsolete.
+
+            if (ulen == 0) {
+                continue;
+            }
+
+            // remove a U+FEFF Unicode signature character if requested
+            if (sig < 0) {
+                if (u.charAt(0) == uSig) {
+                    u.remove(0, 1);
+
+                    // account for the removed UChar and offset
+                    --ulen;
+
+                    if (useOffsets) {
+                        // remove an offset from fromoffsets[] as well
+                        // to keep the array parallel with the UChars
+                        memmove(fromoffsets, fromoffsets + 1, ulen * 4);
+                    }
+
+                }
+                sig = 0;
+            }
+
+#if !UCONFIG_NO_TRANSLITERATION
+            // Transliterate/transform if needed.
+
+            // For transformation, we use chunking code -
+            // collect Unicode input until, for example, an end-of-line,
+            // then transform and output-convert that and continue collecting.
+            // This makes the transformation result independent of the buffer size
+            // while avoiding the slower keyboard mode.
+            // The end-of-chunk characters are completely included in the
+            // transformed string in case they are to be transformed themselves.
+            if (t != NULL) {
+                UnicodeString out;
+                int32_t chunkLimit;
+
+                do {
+                    chunkLimit = getChunkLimit(chunk, u);
+                    if (chunkLimit < 0 && flush && fromSawEndOfBytes) {
+                        // use all of the rest at the end of the text
+                        chunkLimit = u.length();
+                    }
+                    if (chunkLimit >= 0) {
+                        // complete the chunk and transform it
+                        chunk.append(u, 0, chunkLimit);
+                        u.remove(0, chunkLimit);
+                        t->transliterate(chunk);
+
+                        // append the transformation result to the result and empty the chunk
+                        out.append(chunk);
+                        chunk.remove();
+                    } else {
+                        // continue collecting the chunk
+                        chunk.append(u);
+                        break;
+                    }
+                } while (!u.isEmpty());
+
+                u = out;
+                ulen = u.length();
+            }
+#endif
+
+            // add a U+FEFF Unicode signature character if requested
+            // and possible/necessary
+            if (sig > 0) {
+                if (u.charAt(0) != uSig && cnvSigType(convto) == CNV_WITH_FEFF) {
+                    u.insert(0, (UChar)uSig);
+
+                    if (useOffsets) {
+                        // insert a pseudo-offset into fromoffsets[] as well
+                        // to keep the array parallel with the UChars
+                        memmove(fromoffsets + 1, fromoffsets, ulen * 4);
+                        fromoffsets[0] = -1;
+                    }
+
+                    // account for the additional UChar and offset
+                    ++ulen;
+                }
+                sig = 0;
+            }
+
+            // Convert the Unicode buffer into the destination codepage
+            // Again 'bufp' will be placed behind the last converted character
+            // And 'unibufp' will be placed behind the last converted unicode character
+            // At the last conversion flush should be set to true to ensure that
+            // all characters left get converted
+
+            unibuf = unibufbp = u.getBuffer();
+
+            do {
+                bufp = outbuf;
+
+                // Use fromSawEndOfBytes in addition to the flush flag -
+                // it indicates whether the intermediate Unicode string
+                // contains the very last UChars for the very last input bytes.
+                ucnv_fromUnicode(convto, &bufp, outbuf + bufsz,
+                                 &unibufbp,
+                                 unibuf + ulen,
+                                 NULL, (UBool)(flush && fromSawEndOfBytes), &err);
+
+                // toSawEndOfUnicode indicates that ucnv_fromUnicode() is done
+                // converting all of the intermediate UChars.
+                // See comment for fromSawEndOfBytes.
+                toSawEndOfUnicode = (UBool)U_SUCCESS(err);
+
+                if (err == U_BUFFER_OVERFLOW_ERROR) {
+                    err = U_ZERO_ERROR;
+                } else if (U_FAILURE(err)) {
+                    UChar errorUChars[4];
+                    const char *errtag;
+                    char pos[32];
+                    UChar32 c;
+                    int8_t i, length, errorLength;
+
+                    UErrorCode localError = U_ZERO_ERROR;
+                    errorLength = (int8_t)LENGTHOF(errorUChars);
+                    ucnv_getInvalidUChars(convto, errorUChars, &errorLength, &localError);
+                    if (U_FAILURE(localError) || errorLength == 0) {
+                        // need at least 1 so that we don't access beyond the length of fromoffsets[]
+                        errorLength = 1;
+                    }
+
+                    int32_t ferroffset;
+
+                    if (useOffsets) {
+                        // Unicode buffer offset of the start of the error UChars
+                        ferroffset = (int32_t)((unibufbp - unibuf) - errorLength);
+                        if (ferroffset < 0) {
+                            // approximation - the character started in the previous Unicode buffer
+                            ferroffset = 0;
+                        }
+
+                        // get the corresponding byte offset out of fromoffsets[]
+                        // go back if the offset is not known for some of the UChars
+                        int32_t fromoffset;
+                        do {
+                            fromoffset = fromoffsets[ferroffset];
+                        } while (fromoffset < 0 && --ferroffset >= 0);
+
+                        // total input file offset =
+                        // input file offset of the current byte buffer +
+                        // byte buffer offset of where the current Unicode buffer is converted from +
+                        // fromoffsets[Unicode offset]
+                        ferroffset = infoffset + (prevbufp - buf) + fromoffset;
+                        errtag = "problemCvtFromU";
+                    } else {
+                        // Do not use fromoffsets if (t != NULL) because the Unicode text may
+                        // be different from what the offsets refer to.
+
+                        // output file offset
+                        ferroffset = (int32_t)(outfoffset + (bufp - outbuf));
+                        errtag = "problemCvtFromUOut";
+                    }
+
+                    length = (int8_t)sprintf(pos, "%u", (int)ferroffset);
+
+                    // output the code points that caused the error
+                    UnicodeString str;
+                    for (i = 0; i < errorLength;) {
+                        if (i > 0) {
+                            str.append((UChar)uSP);
+                        }
+                        U16_NEXT(errorUChars, i, errorLength, c);
+                        if (c >= 0x100000) {
+                            str.append(nibbleToHex((uint8_t)(c >> 20)));
+                        }
+                        if (c >= 0x10000) {
+                            str.append(nibbleToHex((uint8_t)(c >> 16)));
+                        }
+                        str.append(nibbleToHex((uint8_t)(c >> 12)));
+                        str.append(nibbleToHex((uint8_t)(c >> 8)));
+                        str.append(nibbleToHex((uint8_t)(c >> 4)));
+                        str.append(nibbleToHex((uint8_t)c));
+                    }
+
+                    initMsg(pname);
+                    u_wmsg(stderr, errtag,
+                            UnicodeString(pos, length, "").getTerminatedBuffer(),
+                            str.getTerminatedBuffer(),
+                           u_wmsg_errorName(err));
+                    u_wmsg(stderr, "errorUnicode", str.getTerminatedBuffer());
+
+                    willexit = TRUE;
+                    err = U_ZERO_ERROR; /* reset the error for the rest of the conversion. */
+                }
+
+                // Replaced a check for whether the intermediate Unicode characters were all consumed by
+                // looping until they are; message key "premEnd" now obsolete.
+
+                // Finally, write the converted buffer to the output file
+                size_t outlen = (size_t) (bufp - outbuf);
+                outfoffset += (int32_t)(wr = fwrite(outbuf, 1, outlen, outfile));
+                if (wr != outlen) {
+                    UnicodeString str(strerror(errno));
+                    initMsg(pname);
+                    u_wmsg(stderr, "cantWrite", str.getTerminatedBuffer());
+                    willexit = TRUE;
+                }
+
+                if (willexit) {
+                    goto error_exit;
+                }
+            } while (!toSawEndOfUnicode);
+        } while (!fromSawEndOfBytes);
+    } while (!flush);           // Stop when we have flushed the
+                                // converters (this means that it's
+                                // the end of output)
+
+    goto normal_exit;
+
+error_exit:
+    ret = FALSE;
+
+normal_exit:
+    // Cleanup.
+
+    ucnv_close(convfrom);
+    ucnv_close(convto);
+
+#if !UCONFIG_NO_TRANSLITERATION
+    delete t;
+#endif
+
+    if (infile != stdin) {
+        fclose(infile);
+    }
+
+    return ret;
+}
+
+static void usage(const char *pname, int ecode) {
+    const UChar *msg;
+    int32_t msgLen;
+    UErrorCode err = U_ZERO_ERROR;
+    FILE *fp = ecode ? stderr : stdout;
+    int res;
+
+    initMsg(pname);
+    msg =
+        ures_getStringByKey(gBundle, ecode ? "lcUsageWord" : "ucUsageWord",
+                            &msgLen, &err);
+    UnicodeString upname(pname, (int32_t)(uprv_strlen(pname) + 1));
+    UnicodeString mname(msg, msgLen + 1);
+
+    res = u_wmsg(fp, "usage", mname.getBuffer(), upname.getBuffer());
+    if (!ecode) {
+        if (!res) {
+            fputc('\n', fp);
+        }
+        if (!u_wmsg(fp, "help")) {
+            /* Now dump callbacks and finish. */
+
+            int i, count =
+                sizeof(transcode_callbacks) / sizeof(*transcode_callbacks);
+            for (i = 0; i < count; ++i) {
+                fprintf(fp, " %s", transcode_callbacks[i].name);
+            }
+            fputc('\n', fp);
+        }
+    }
+
+    exit(ecode);
+}
+
+extern int
+main(int argc, char **argv)
+{
+    FILE *outfile;
+    int ret = 0;
+
+    size_t bufsz = DEFAULT_BUFSZ;
+
+    const char *fromcpage = 0;
+    const char *tocpage = 0;
+    const char *translit = 0;
+    const char *outfilestr = 0;
+    UBool fallback = FALSE;
+
+    UConverterFromUCallback fromucallback = UCNV_FROM_U_CALLBACK_STOP;
+    const void *fromuctxt = 0;
+    UConverterToUCallback toucallback = UCNV_TO_U_CALLBACK_STOP;
+    const void *touctxt = 0;
+
+    char **iter, **remainArgv, **remainArgvLimit;
+    char **end = argv + argc;
+
+    const char *pname;
+
+    UBool printConvs = FALSE, printCanon = FALSE, printTranslits = FALSE;
+    const char *printName = 0;
+
+    UBool verbose = FALSE;
+    UErrorCode status = U_ZERO_ERROR;
+
+    ConvertFile cf;
+
+    /* Initialize ICU */
+    u_init(&status);
+    if (U_FAILURE(status)) {
+        fprintf(stderr, "%s: can not initialize ICU.  status = %s\n",
+            argv[0], u_errorName(status));
+        exit(1);
+    }
+
+    // Get and prettify pname.
+    pname = uprv_strrchr(*argv, U_FILE_SEP_CHAR);
+#ifdef U_WINDOWS
+    if (!pname) {
+        pname = uprv_strrchr(*argv, '/');
+    }
+#endif
+    if (!pname) {
+        pname = *argv;
+    } else {
+        ++pname;
+    }
+
+    // First, get the arguments from command-line
+    // to know the codepages to convert between
+
+    remainArgv = remainArgvLimit = argv + 1;
+    for (iter = argv + 1; iter != end; iter++) {
+        // Check for from charset
+        if (strcmp("-f", *iter) == 0 || !strcmp("--from-code", *iter)) {
+            iter++;
+            if (iter != end)
+                fromcpage = *iter;
+            else
+                usage(pname, 1);
+        } else if (strcmp("-t", *iter) == 0 || !strcmp("--to-code", *iter)) {
+            iter++;
+            if (iter != end)
+                tocpage = *iter;
+            else
+                usage(pname, 1);
+        } else if (strcmp("-x", *iter) == 0) {
+            iter++;
+            if (iter != end)
+                translit = *iter;
+            else
+                usage(pname, 1);
+        } else if (!strcmp("--fallback", *iter)) {
+            fallback = TRUE;
+        } else if (!strcmp("--no-fallback", *iter)) {
+            fallback = FALSE;
+        } else if (strcmp("-b", *iter) == 0 || !strcmp("--block-size", *iter)) {
+            iter++;
+            if (iter != end) {
+                bufsz = atoi(*iter);
+                if ((int) bufsz <= 0) {
+                    initMsg(pname);
+                    UnicodeString str(*iter);
+                    initMsg(pname);
+                    u_wmsg(stderr, "badBlockSize", str.getTerminatedBuffer());
+                    return 3;
+                }
+            } else {
+                usage(pname, 1);
+            }
+        } else if (strcmp("-l", *iter) == 0 || !strcmp("--list", *iter)) {
+            if (printTranslits) {
+                usage(pname, 1);
+            }
+            printConvs = TRUE;
+        } else if (strcmp("--default-code", *iter) == 0) {
+            if (printTranslits) {
+                usage(pname, 1);
+            }
+            printName = ucnv_getDefaultName();
+        } else if (strcmp("--list-code", *iter) == 0) {
+            if (printTranslits) {
+                usage(pname, 1);
+            }
+
+            iter++;
+            if (iter != end) {
+                UErrorCode e = U_ZERO_ERROR;
+                printName = ucnv_getAlias(*iter, 0, &e);
+                if (U_FAILURE(e) || !printName) {
+                    UnicodeString str(*iter);
+                    initMsg(pname);
+                    u_wmsg(stderr, "noSuchCodeset", str.getTerminatedBuffer());
+                    return 2;
+                }
+            } else
+                usage(pname, 1);
+        } else if (strcmp("--canon", *iter) == 0) {
+            printCanon = TRUE;
+        } else if (strcmp("-L", *iter) == 0
+            || !strcmp("--list-transliterators", *iter)) {
+            if (printConvs) {
+                usage(pname, 1);
+            }
+            printTranslits = TRUE;
+        } else if (strcmp("-h", *iter) == 0 || !strcmp("-?", *iter)
+            || !strcmp("--help", *iter)) {
+            usage(pname, 0);
+        } else if (!strcmp("-c", *iter)) {
+            fromucallback = UCNV_FROM_U_CALLBACK_SKIP;
+        } else if (!strcmp("--to-callback", *iter)) {
+            iter++;
+            if (iter != end) {
+                const struct callback_ent *cbe = findCallback(*iter);
+                if (cbe) {
+                    fromucallback = cbe->fromu;
+                    fromuctxt = cbe->fromuctxt;
+                } else {
+                    UnicodeString str(*iter);
+                    initMsg(pname);
+                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
+                    return 4;
+                }
+            } else {
+                usage(pname, 1);
+            }
+        } else if (!strcmp("--from-callback", *iter)) {
+            iter++;
+            if (iter != end) {
+                const struct callback_ent *cbe = findCallback(*iter);
+                if (cbe) {
+                    toucallback = cbe->tou;
+                    touctxt = cbe->touctxt;
+                } else {
+                    UnicodeString str(*iter);
+                    initMsg(pname);
+                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
+                    return 4;
+                }
+            } else {
+                usage(pname, 1);
+            }
+        } else if (!strcmp("-i", *iter)) {
+            toucallback = UCNV_TO_U_CALLBACK_SKIP;
+        } else if (!strcmp("--callback", *iter)) {
+            iter++;
+            if (iter != end) {
+                const struct callback_ent *cbe = findCallback(*iter);
+                if (cbe) {
+                    fromucallback = cbe->fromu;
+                    fromuctxt = cbe->fromuctxt;
+                    toucallback = cbe->tou;
+                    touctxt = cbe->touctxt;
+                } else {
+                    UnicodeString str(*iter);
+                    initMsg(pname);
+                    u_wmsg(stderr, "unknownCallback", str.getTerminatedBuffer());
+                    return 4;
+                }
+            } else {
+                usage(pname, 1);
+            }
+        } else if (!strcmp("-s", *iter) || !strcmp("--silent", *iter)) {
+            verbose = FALSE;
+        } else if (!strcmp("-v", *iter) || !strcmp("--verbose", *iter)) {
+            verbose = TRUE;
+        } else if (!strcmp("-V", *iter) || !strcmp("--version", *iter)) {
+            printf("%s v2.1  ICU " U_ICU_VERSION "\n", pname);
+            return 0;
+        } else if (!strcmp("-o", *iter) || !strcmp("--output", *iter)) {
+            ++iter;
+            if (iter != end && !outfilestr) {
+                outfilestr = *iter;
+            } else {
+                usage(pname, 1);
+            }
+        } else if (0 == strcmp("--add-signature", *iter)) {
+            cf.signature = 1;
+        } else if (0 == strcmp("--remove-signature", *iter)) {
+            cf.signature = -1;
+        } else if (**iter == '-' && (*iter)[1]) {
+            usage(pname, 1);
+        } else {
+            // move a non-option up in argv[]
+            *remainArgvLimit++ = *iter;
+        }
+    }
+
+    if (printConvs || printName) {
+        return printConverters(pname, printName, printCanon) ? 2 : 0;
+    } else if (printTranslits) {
+        return printTransliterators(printCanon) ? 3 : 0;
+    }
+
+    if (!fromcpage || !uprv_strcmp(fromcpage, "-")) {
+        fromcpage = ucnv_getDefaultName();
+    }
+    if (!tocpage || !uprv_strcmp(tocpage, "-")) {
+        tocpage = ucnv_getDefaultName();
+    }
+
+    // Open the correct output file or connect to stdout for reading input
+    if (outfilestr != 0 && strcmp(outfilestr, "-")) {
+        outfile = fopen(outfilestr, "wb");
+        if (outfile == 0) {
+            UnicodeString str1(outfilestr, "");
+            UnicodeString str2(strerror(errno), "");
+            initMsg(pname);
+            u_wmsg(stderr, "cantCreateOutputF",
+                str1.getBuffer(), str2.getBuffer());
+            return 1;
+        }
+    } else {
+        outfilestr = "-";
+        outfile = stdout;
+#ifdef USE_FILENO_BINARY_MODE
+        if (setmode(fileno(outfile), O_BINARY) == -1) {
+            u_wmsg(stderr, "cantSetOutBinMode");
+            exit(-1);
+        }
+#endif
+    }
+
+    /* Loop again on the arguments to find all the input files, and
+    convert them. */
+
+    cf.setBufferSize(bufsz);
+
+    if(remainArgv < remainArgvLimit) {
+        for (iter = remainArgv; iter != remainArgvLimit; iter++) {
+            if (!cf.convertFile(
+                    pname, fromcpage, toucallback, touctxt, tocpage,
+                    fromucallback, fromuctxt, fallback, translit, *iter,
+                    outfile, verbose)
+            ) {
+                goto error_exit;
+            }
+        }
+    } else {
+        if (!cf.convertFile(
+                pname, fromcpage, toucallback, touctxt, tocpage,
+                fromucallback, fromuctxt, fallback, translit, 0,
+                outfile, verbose)
+        ) {
+            goto error_exit;
+        }
+    }
+
+    goto normal_exit;
+error_exit:
+    ret = 1;
+normal_exit:
+
+    if (outfile != stdout) {
+        fclose(outfile);
+    }
+
+    return ret;
+}
+
+
+/*
+ * Hey, Emacs, please set the following:
+ *
+ * Local Variables:
+ * indent-tabs-mode: nil
+ * End:
+ *
+ */


Property changes on: trunk/source/extra/uconv/uconv.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/unicode/uwmsg.h
===================================================================
--- trunk/source/extra/uconv/unicode/uwmsg.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/unicode/uwmsg.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,29 +1,29 @@
-/*
-**********************************************************************
-* Copyright (C) 2000-2004, International Business Machines Corporation 
-* and others.  All Rights Reserved.
-**********************************************************************
-
-Get a message out of the default resource bundle, messageformat it,
-and print it to stderr
-*/
-
-#ifndef _UWMSG
-#define _UWMSG
-
-#include <stdio.h>
-
-#include "unicode/ures.h"
-
-/* Set the path to wmsg's bundle.
-   Caller owns storage.
-*/
-U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err);
-
-/* Format a message and print it's output to a given file stream */
-U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... );
-
-/* format an error message */
-U_CFUNC const UChar* u_wmsg_errorName(UErrorCode err);
-
-#endif
+/*
+**********************************************************************
+* Copyright (C) 2000-2004, International Business Machines Corporation 
+* and others.  All Rights Reserved.
+**********************************************************************
+
+Get a message out of the default resource bundle, messageformat it,
+and print it to stderr
+*/
+
+#ifndef _UWMSG
+#define _UWMSG
+
+#include <stdio.h>
+
+#include "unicode/ures.h"
+
+/* Set the path to wmsg's bundle.
+   Caller owns storage.
+*/
+U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err);
+
+/* Format a message and print it's output to a given file stream */
+U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... );
+
+/* format an error message */
+U_CFUNC const UChar* u_wmsg_errorName(UErrorCode err);
+
+#endif


Property changes on: trunk/source/extra/uconv/unicode/uwmsg.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/extra/uconv/uwmsg.c
===================================================================
--- trunk/source/extra/uconv/uwmsg.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/extra/uconv/uwmsg.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,269 +1,269 @@
-/*
-**********************************************************************
-* Copyright (C) 1998-2004, International Business Machines Corporation 
-* and others.  All Rights Reserved.
-**********************************************************************
-*
-* File uwmsg.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   06/14/99    stephen     Creation.
-*******************************************************************************
-*/
-
-#include "unicode/ucnv.h"
-#include "unicode/ustring.h"
-#include "unicode/umsg.h"
-#include "unicode/uwmsg.h"
-#include "unicode/ures.h"
-#include "unicode/putil.h"
-#include "cstring.h"
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-
-#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
-
-#define BUF_SIZE 128
-
-/* Print a ustring to the specified FILE* in the default codepage */
-static void
-uprint(const UChar *s,
-       int32_t sourceLen,
-       FILE *f,
-       UErrorCode *status)
-{
-    /* converter */
-    UConverter *converter;
-    char buf [BUF_SIZE];
-    const UChar *mySource;
-    const UChar *mySourceEnd;
-    char *myTarget;
-    int32_t arraySize;
-
-    if(s == 0) return;
-
-    /* set up the conversion parameters */
-    mySource     = s;
-    mySourceEnd  = mySource + sourceLen;
-    myTarget     = buf;
-    arraySize    = BUF_SIZE;
-
-    /* open a default converter */
-    converter = ucnv_open(0, status);
-
-    /* if we failed, clean up and exit */
-    if(U_FAILURE(*status)) goto finish;
-
-    /* perform the conversion */
-    do {
-        /* reset the error code */
-        *status = U_ZERO_ERROR;
-
-        /* perform the conversion */
-        ucnv_fromUnicode(converter, &myTarget,  myTarget + arraySize,
-            &mySource, mySourceEnd, NULL,
-            TRUE, status);
-
-        /* Write the converted data to the FILE* */
-        fwrite(buf, sizeof(char), myTarget - buf, f);
-
-        /* update the conversion parameters*/
-        myTarget     = buf;
-        arraySize    = BUF_SIZE;
-    }
-    while(*status == U_BUFFER_OVERFLOW_ERROR); 
-
-finish:
-
-    /* close the converter */
-    ucnv_close(converter);
-}
-
-static const char *gPath = 0;
-static UResourceBundle *gBundle = NULL;
-
-U_STRING_DECL(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
-
-U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err)
-{
-  if(U_FAILURE(*err))
-  {
-    return 0;
-  }
-
-  if(gBundle != NULL)
-  {
-    *err = U_ILLEGAL_ARGUMENT_ERROR;
-    return 0;
-  }
-  else
-  {
-    UResourceBundle *b = NULL;
-    b = ures_open(path, NULL, err);
-    if(U_FAILURE(*err))
-    {
-         return 0;
-    }
-
-    gPath = uprv_strdup(path);
-    gBundle = b;
-
-    U_STRING_INIT(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
-  }
-  
-  return gBundle;
-}
-
-/* Format a message and print it's output to fp */
-U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... )
-{
-    const UChar *msg;
-    int32_t      msgLen;
-    UErrorCode  err = U_ZERO_ERROR;
-#if !UCONFIG_NO_FORMATTING
-    va_list ap;
-#endif
-    UChar   result[4096];
-    int32_t resultLength = LENGTHOF(result);
-
-    if(gBundle == NULL)
-    {
-#if 0
-        fprintf(stderr, "u_wmsg: No path set!!\n"); /* FIXME: codepage?? */
-#endif
-        return -1;
-    }
-
-    msg = ures_getStringByKey(gBundle, tag, &msgLen, &err);
-
-    if(U_FAILURE(err))
-    {
-#if 0
-        fprintf(stderr, "u_wmsg: failed to load tag [%s] [%s] [%s]!!\n", tag,  u_errorName(err), gPath);
-#endif
-        return -1;
-    }
-
-#if UCONFIG_NO_FORMATTING
-    resultLength = sizeof(gNoFormatting) / U_SIZEOF_UCHAR;
-    if((msgLen + resultLength) <= LENGTHOF(result)) {
-        memcpy(result, msg, msgLen * U_SIZEOF_UCHAR);
-        memcpy(result + msgLen, gNoFormatting, resultLength);
-        resultLength += msgLen;
-        uprint(result, resultLength, fp, &err);
-    } else {
-        uprint(msg,msgLen, fp, &err);
-    }
-#else
-    va_start(ap, tag);
-
-    resultLength = u_vformatMessage(uloc_getDefault(), msg, msgLen, result, resultLength, ap, &err);
-
-    va_end(ap);
-
-    if(U_FAILURE(err))
-    {
-#if 0
-        fprintf(stderr, "u_wmsg: failed to format %s:%s, err %s\n",
-            uloc_getDefault(),
-            tag,
-            u_errorName(err));
-#endif
-        err = U_ZERO_ERROR;
-        uprint(msg,msgLen, fp, &err);
-        return -1;
-    }
-
-    uprint(result, resultLength, fp, &err);
-#endif
-
-    if(U_FAILURE(err))
-    {
-#if 0
-        fprintf(stderr, "u_wmsg: failed to print %s: %s, err %s\n",
-            uloc_getDefault(),
-            tag,
-            u_errorName(err));
-#endif
-        return -1;
-    }
-
-    return 0;
-}
-
-/* these will break if the # of messages change. simply add or remove 0's .. */
-UChar **gInfoMessages = NULL;
-
-UChar **gErrMessages = NULL;
-
-static const UChar *fetchErrorName(UErrorCode err)
-{
-    if (!gInfoMessages) {
-        gInfoMessages = (UChar **)malloc((U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*));
-        memset(gInfoMessages, 0, (U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*));
-    }
-    if (!gErrMessages) {
-        gErrMessages = (UChar **)malloc(U_ERROR_LIMIT*sizeof(UChar*));
-        memset(gErrMessages, 0, U_ERROR_LIMIT*sizeof(UChar*));
-    }
-    if(err>=0)
-        return gErrMessages[err];
-    else
-        return gInfoMessages[err-U_ERROR_WARNING_START];
-}
-
-U_CFUNC const UChar *u_wmsg_errorName(UErrorCode err)
-{
-    UChar *msg;
-    int32_t msgLen;
-    UErrorCode subErr = U_ZERO_ERROR;
-    const char *textMsg = NULL;
-
-    /* try the cache */
-    msg = (UChar*)fetchErrorName(err);
-
-    if(msg)
-    {
-        return msg;
-    }
-
-    if(gBundle == NULL)
-    {
-        msg = NULL;
-    }
-    else
-    {
-        const char *errname = u_errorName(err);
-        if (errname) {
-            msg = (UChar*)ures_getStringByKey(gBundle, errname, &msgLen, &subErr);
-            if(U_FAILURE(subErr))
-            {
-                msg = NULL;
-            }
-        }
-    }
-
-    if(msg == NULL)  /* Couldn't find it anywhere.. */
-    {
-        char error[128];
-        textMsg = u_errorName(err);
-        if (!textMsg) {
-            sprintf(error, "UNDOCUMENTED ICU ERROR %d", err);
-            textMsg = error;
-        }
-        msg = (UChar*)malloc((strlen(textMsg)+1)*sizeof(msg[0]));
-        u_charsToUChars(textMsg, msg, (int32_t)(strlen(textMsg)+1));
-    }
-
-    if(err>=0)
-        gErrMessages[err] = msg;
-    else
-        gInfoMessages[err-U_ERROR_WARNING_START] = msg;
-
-    return msg;
-}
+/*
+**********************************************************************
+* Copyright (C) 1998-2004, International Business Machines Corporation 
+* and others.  All Rights Reserved.
+**********************************************************************
+*
+* File uwmsg.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   06/14/99    stephen     Creation.
+*******************************************************************************
+*/
+
+#include "unicode/ucnv.h"
+#include "unicode/ustring.h"
+#include "unicode/umsg.h"
+#include "unicode/uwmsg.h"
+#include "unicode/ures.h"
+#include "unicode/putil.h"
+#include "cstring.h"
+
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0]))
+
+#define BUF_SIZE 128
+
+/* Print a ustring to the specified FILE* in the default codepage */
+static void
+uprint(const UChar *s,
+       int32_t sourceLen,
+       FILE *f,
+       UErrorCode *status)
+{
+    /* converter */
+    UConverter *converter;
+    char buf [BUF_SIZE];
+    const UChar *mySource;
+    const UChar *mySourceEnd;
+    char *myTarget;
+    int32_t arraySize;
+
+    if(s == 0) return;
+
+    /* set up the conversion parameters */
+    mySource     = s;
+    mySourceEnd  = mySource + sourceLen;
+    myTarget     = buf;
+    arraySize    = BUF_SIZE;
+
+    /* open a default converter */
+    converter = ucnv_open(0, status);
+
+    /* if we failed, clean up and exit */
+    if(U_FAILURE(*status)) goto finish;
+
+    /* perform the conversion */
+    do {
+        /* reset the error code */
+        *status = U_ZERO_ERROR;
+
+        /* perform the conversion */
+        ucnv_fromUnicode(converter, &myTarget,  myTarget + arraySize,
+            &mySource, mySourceEnd, NULL,
+            TRUE, status);
+
+        /* Write the converted data to the FILE* */
+        fwrite(buf, sizeof(char), myTarget - buf, f);
+
+        /* update the conversion parameters*/
+        myTarget     = buf;
+        arraySize    = BUF_SIZE;
+    }
+    while(*status == U_BUFFER_OVERFLOW_ERROR); 
+
+finish:
+
+    /* close the converter */
+    ucnv_close(converter);
+}
+
+static const char *gPath = 0;
+static UResourceBundle *gBundle = NULL;
+
+U_STRING_DECL(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
+
+U_CFUNC UResourceBundle *u_wmsg_setPath(const char *path, UErrorCode *err)
+{
+  if(U_FAILURE(*err))
+  {
+    return 0;
+  }
+
+  if(gBundle != NULL)
+  {
+    *err = U_ILLEGAL_ARGUMENT_ERROR;
+    return 0;
+  }
+  else
+  {
+    UResourceBundle *b = NULL;
+    b = ures_open(path, NULL, err);
+    if(U_FAILURE(*err))
+    {
+         return 0;
+    }
+
+    gPath = uprv_strdup(path);
+    gBundle = b;
+
+    U_STRING_INIT(gNoFormatting, " (UCONFIG_NO_FORMATTING see uconfig.h)", 38);
+  }
+  
+  return gBundle;
+}
+
+/* Format a message and print it's output to fp */
+U_CFUNC int u_wmsg(FILE *fp, const char *tag, ... )
+{
+    const UChar *msg;
+    int32_t      msgLen;
+    UErrorCode  err = U_ZERO_ERROR;
+#if !UCONFIG_NO_FORMATTING
+    va_list ap;
+#endif
+    UChar   result[4096];
+    int32_t resultLength = LENGTHOF(result);
+
+    if(gBundle == NULL)
+    {
+#if 0
+        fprintf(stderr, "u_wmsg: No path set!!\n"); /* FIXME: codepage?? */
+#endif
+        return -1;
+    }
+
+    msg = ures_getStringByKey(gBundle, tag, &msgLen, &err);
+
+    if(U_FAILURE(err))
+    {
+#if 0
+        fprintf(stderr, "u_wmsg: failed to load tag [%s] [%s] [%s]!!\n", tag,  u_errorName(err), gPath);
+#endif
+        return -1;
+    }
+
+#if UCONFIG_NO_FORMATTING
+    resultLength = sizeof(gNoFormatting) / U_SIZEOF_UCHAR;
+    if((msgLen + resultLength) <= LENGTHOF(result)) {
+        memcpy(result, msg, msgLen * U_SIZEOF_UCHAR);
+        memcpy(result + msgLen, gNoFormatting, resultLength);
+        resultLength += msgLen;
+        uprint(result, resultLength, fp, &err);
+    } else {
+        uprint(msg,msgLen, fp, &err);
+    }
+#else
+    va_start(ap, tag);
+
+    resultLength = u_vformatMessage(uloc_getDefault(), msg, msgLen, result, resultLength, ap, &err);
+
+    va_end(ap);
+
+    if(U_FAILURE(err))
+    {
+#if 0
+        fprintf(stderr, "u_wmsg: failed to format %s:%s, err %s\n",
+            uloc_getDefault(),
+            tag,
+            u_errorName(err));
+#endif
+        err = U_ZERO_ERROR;
+        uprint(msg,msgLen, fp, &err);
+        return -1;
+    }
+
+    uprint(result, resultLength, fp, &err);
+#endif
+
+    if(U_FAILURE(err))
+    {
+#if 0
+        fprintf(stderr, "u_wmsg: failed to print %s: %s, err %s\n",
+            uloc_getDefault(),
+            tag,
+            u_errorName(err));
+#endif
+        return -1;
+    }
+
+    return 0;
+}
+
+/* these will break if the # of messages change. simply add or remove 0's .. */
+UChar **gInfoMessages = NULL;
+
+UChar **gErrMessages = NULL;
+
+static const UChar *fetchErrorName(UErrorCode err)
+{
+    if (!gInfoMessages) {
+        gInfoMessages = (UChar **)malloc((U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*));
+        memset(gInfoMessages, 0, (U_ERROR_WARNING_LIMIT-U_ERROR_WARNING_START)*sizeof(UChar*));
+    }
+    if (!gErrMessages) {
+        gErrMessages = (UChar **)malloc(U_ERROR_LIMIT*sizeof(UChar*));
+        memset(gErrMessages, 0, U_ERROR_LIMIT*sizeof(UChar*));
+    }
+    if(err>=0)
+        return gErrMessages[err];
+    else
+        return gInfoMessages[err-U_ERROR_WARNING_START];
+}
+
+U_CFUNC const UChar *u_wmsg_errorName(UErrorCode err)
+{
+    UChar *msg;
+    int32_t msgLen;
+    UErrorCode subErr = U_ZERO_ERROR;
+    const char *textMsg = NULL;
+
+    /* try the cache */
+    msg = (UChar*)fetchErrorName(err);
+
+    if(msg)
+    {
+        return msg;
+    }
+
+    if(gBundle == NULL)
+    {
+        msg = NULL;
+    }
+    else
+    {
+        const char *errname = u_errorName(err);
+        if (errname) {
+            msg = (UChar*)ures_getStringByKey(gBundle, errname, &msgLen, &subErr);
+            if(U_FAILURE(subErr))
+            {
+                msg = NULL;
+            }
+        }
+    }
+
+    if(msg == NULL)  /* Couldn't find it anywhere.. */
+    {
+        char error[128];
+        textMsg = u_errorName(err);
+        if (!textMsg) {
+            sprintf(error, "UNDOCUMENTED ICU ERROR %d", err);
+            textMsg = error;
+        }
+        msg = (UChar*)malloc((strlen(textMsg)+1)*sizeof(msg[0]));
+        u_charsToUChars(textMsg, msg, (int32_t)(strlen(textMsg)+1));
+    }
+
+    if(err>=0)
+        gErrMessages[err] = msg;
+    else
+        gInfoMessages[err-U_ERROR_WARNING_START] = msg;
+
+    return msg;
+}


Property changes on: trunk/source/extra/uconv/uwmsg.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/Makefile.in
===================================================================
--- trunk/source/io/Makefile.in	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/Makefile.in	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,163 +1,163 @@
-#******************************************************************************
-#
-#   Copyright (C) 1999-2006, International Business Machines
-#   Corporation and others.  All Rights Reserved.
-#
-#******************************************************************************
-## Makefile.in for ICU - icuio.so
-## Stephen F. Booth
-
-## Source directory information
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-
-top_builddir = ..
-
-## All the flags and other definitions are included here.
-include $(top_builddir)/icudefs.mk
-
-## Build directory information
-subdir = io
-
-## Extra files to remove for 'make clean'
-CLEANFILES = *~ $(DEPS) $(IMPORT_LIB) $(MIDDLE_IMPORT_LIB) $(FINAL_IMPORT_LIB)
-
-## Target information
-
-TARGET_STUBNAME=$(IO_STUBNAME)
-
-ifneq ($(ENABLE_STATIC),)
-TARGET = $(LIBDIR)/$(LIBSICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX).$(A)
-endif
-
-ifneq ($(ENABLE_SHARED),)
-SO_TARGET = $(LIBDIR)/$(LIBICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX).$(SO)
-ALL_SO_TARGETS = $(SO_TARGET) $(MIDDLE_SO_TARGET) $(FINAL_SO_TARGET) $(SHARED_OBJECT)
-
-ifeq ($(ENABLE_SO_VERSION_DATA),1)
-SO_VERSION_DATA = io.res
-endif
-
-ifeq ($(OS390BATCH),1)
-BATCH_TARGET = $(BATCH_IO_TARGET)
-BATCH_LIBS = $(BATCH_LIBICUUC) $(BATCH_LIBICUI18N) -lm
-endif   # OS390BATCH
-
-endif   # ENABLE_SHARED
-
-ALL_TARGETS = $(TARGET) $(ALL_SO_TARGETS) $(BATCH_TARGET)
-
-DYNAMICCPPFLAGS = $(SHAREDLIBCPPFLAGS)
-DYNAMICCFLAGS = $(SHAREDLIBCFLAGS)
-DYNAMICCXXFLAGS = $(SHAREDLIBCXXFLAGS)
-
-ifneq ($(top_builddir),$(top_srcdir))
-CPPFLAGS += -I$(top_builddir)/common
-endif
-CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n $(LIBCPPFLAGS)
-DEFS += -DU_IO_IMPLEMENTATION
-LDFLAGS += $(LDFLAGSICUIO)
-LIBS = $(LIBICUUC) $(LIBICUI18N) $(DEFAULT_LIBS)
-
-OBJECTS = locbund.o ufile.o ufmt_cmn.o uprintf.o uprntf_p.o \
-uscanf.o uscanf_p.o ustdio.o sprintf.o sscanf.o \
-ustream.o ucln_io.o
-
-## Header files to install
-HEADERS = $(srcdir)/unicode/*.h
-
-STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O))
-
-DEPS = $(OBJECTS:.o=.d)
-
--include Makefile.local
-
-## List of phony targets
-.PHONY : all all-local install install-local clean clean-local	\
-distclean distclean-local install-library install-headers dist	\
-dist-local check check-local
-
-## Clear suffix list
-.SUFFIXES :
-
-## List of standard targets
-all: all-local
-install: install-local
-clean: clean-local
-distclean : distclean-local
-dist: dist-local
-check: all check-local
-
-all-local: $(ALL_TARGETS)
-
-install-local: install-headers install-library
-
-install-library: all-local
-	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
-ifneq ($(ENABLE_STATIC),)
-	$(INSTALL-L) $(TARGET) $(DESTDIR)$(libdir)
-endif
-ifneq ($(ENABLE_SHARED),)
-	$(INSTALL-L) $(FINAL_SO_TARGET) $(DESTDIR)$(libdir)
-ifneq ($(FINAL_SO_TARGET),$(SO_TARGET))
-	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(SO_TARGET))
-ifneq ($(FINAL_SO_TARGET),$(MIDDLE_SO_TARGET))
-	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(MIDDLE_SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(MIDDLE_SO_TARGET))
-endif
-endif
-endif
-ifneq ($(IMPORT_LIB_EXT),)
-	$(INSTALL-L) $(FINAL_IMPORT_LIB) $(DESTDIR)$(libdir)
-ifneq ($(IMPORT_LIB),$(FINAL_IMPORT_LIB))
-	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(IMPORT_LIB)) && ln -s $(notdir $(FINAL_IMPORT_LIB)) $(notdir $(IMPORT_LIB))
-endif
-ifneq ($(MIDDLE_IMPORT_LIB),$(FINAL_IMPORT_LIB))
-	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(MIDDLE_IMPORT_LIB)) && ln -s $(notdir $(FINAL_IMPORT_LIB)) $(notdir $(MIDDLE_IMPORT_LIB))
-endif
-endif
-
-install-headers:
-	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)/unicode
-	@for file in $(HEADERS); do \
-	 echo "$(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/unicode"; \
-	 $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/unicode || exit; \
-	done
-
-dist-local:
-
-clean-local:
-	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
-	$(RMV) $(OBJECTS) $(STATIC_OBJECTS) $(ALL_TARGETS) $(SO_VERSION_DATA)
-
-distclean-local: clean-local
-	$(RMV) Makefile
-
-check-local:
-
-Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
-	cd $(top_builddir) \
-	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
-
-ifneq ($(ENABLE_STATIC),)
-$(TARGET): $(TARGET)($(STATIC_OBJECTS))
-	$(RANLIB) $@
-endif
-
-ifneq ($(ENABLE_SHARED),)
-$(SHARED_OBJECT): $(OBJECTS) $(SO_VERSION_DATA)
-	$(SHLIB.cc) $(LD_SONAME) $(OUTOPT)$@ $^ $(LIBS)
-
-ifeq ($(OS390BATCH),1)
-$(BATCH_TARGET):$(OBJECTS)
-	$(SHLIB.cc) $(LD_SONAME) $(OUTOPT)$@ $^ $(BATCH_LIBS)
-endif   # OS390BATCH
-endif   # ENABLE_SHARED
-
-ifeq (,$(MAKECMDGOALS))
--include $(DEPS)
-else
-ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
--include $(DEPS)
-endif
-endif
-
+#******************************************************************************
+#
+#   Copyright (C) 1999-2006, International Business Machines
+#   Corporation and others.  All Rights Reserved.
+#
+#******************************************************************************
+## Makefile.in for ICU - icuio.so
+## Stephen F. Booth
+
+## Source directory information
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+
+top_builddir = ..
+
+## All the flags and other definitions are included here.
+include $(top_builddir)/icudefs.mk
+
+## Build directory information
+subdir = io
+
+## Extra files to remove for 'make clean'
+CLEANFILES = *~ $(DEPS) $(IMPORT_LIB) $(MIDDLE_IMPORT_LIB) $(FINAL_IMPORT_LIB)
+
+## Target information
+
+TARGET_STUBNAME=$(IO_STUBNAME)
+
+ifneq ($(ENABLE_STATIC),)
+TARGET = $(LIBDIR)/$(LIBSICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX).$(A)
+endif
+
+ifneq ($(ENABLE_SHARED),)
+SO_TARGET = $(LIBDIR)/$(LIBICU)$(TARGET_STUBNAME)$(ICULIBSUFFIX).$(SO)
+ALL_SO_TARGETS = $(SO_TARGET) $(MIDDLE_SO_TARGET) $(FINAL_SO_TARGET) $(SHARED_OBJECT)
+
+ifeq ($(ENABLE_SO_VERSION_DATA),1)
+SO_VERSION_DATA = io.res
+endif
+
+ifeq ($(OS390BATCH),1)
+BATCH_TARGET = $(BATCH_IO_TARGET)
+BATCH_LIBS = $(BATCH_LIBICUUC) $(BATCH_LIBICUI18N) -lm
+endif   # OS390BATCH
+
+endif   # ENABLE_SHARED
+
+ALL_TARGETS = $(TARGET) $(ALL_SO_TARGETS) $(BATCH_TARGET)
+
+DYNAMICCPPFLAGS = $(SHAREDLIBCPPFLAGS)
+DYNAMICCFLAGS = $(SHAREDLIBCFLAGS)
+DYNAMICCXXFLAGS = $(SHAREDLIBCXXFLAGS)
+
+ifneq ($(top_builddir),$(top_srcdir))
+CPPFLAGS += -I$(top_builddir)/common
+endif
+CPPFLAGS += -I$(top_srcdir)/common -I$(top_srcdir)/i18n $(LIBCPPFLAGS)
+DEFS += -DU_IO_IMPLEMENTATION
+LDFLAGS += $(LDFLAGSICUIO)
+LIBS = $(LIBICUUC) $(LIBICUI18N) $(DEFAULT_LIBS)
+
+OBJECTS = locbund.o ufile.o ufmt_cmn.o uprintf.o uprntf_p.o \
+uscanf.o uscanf_p.o ustdio.o sprintf.o sscanf.o \
+ustream.o ucln_io.o
+
+## Header files to install
+HEADERS = $(srcdir)/unicode/*.h
+
+STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O))
+
+DEPS = $(OBJECTS:.o=.d)
+
+-include Makefile.local
+
+## List of phony targets
+.PHONY : all all-local install install-local clean clean-local	\
+distclean distclean-local install-library install-headers dist	\
+dist-local check check-local
+
+## Clear suffix list
+.SUFFIXES :
+
+## List of standard targets
+all: all-local
+install: install-local
+clean: clean-local
+distclean : distclean-local
+dist: dist-local
+check: all check-local
+
+all-local: $(ALL_TARGETS)
+
+install-local: install-headers install-library
+
+install-library: all-local
+	$(MKINSTALLDIRS) $(DESTDIR)$(libdir)
+ifneq ($(ENABLE_STATIC),)
+	$(INSTALL-L) $(TARGET) $(DESTDIR)$(libdir)
+endif
+ifneq ($(ENABLE_SHARED),)
+	$(INSTALL-L) $(FINAL_SO_TARGET) $(DESTDIR)$(libdir)
+ifneq ($(FINAL_SO_TARGET),$(SO_TARGET))
+	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(SO_TARGET))
+ifneq ($(FINAL_SO_TARGET),$(MIDDLE_SO_TARGET))
+	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(MIDDLE_SO_TARGET)) && ln -s $(notdir $(FINAL_SO_TARGET)) $(notdir $(MIDDLE_SO_TARGET))
+endif
+endif
+endif
+ifneq ($(IMPORT_LIB_EXT),)
+	$(INSTALL-L) $(FINAL_IMPORT_LIB) $(DESTDIR)$(libdir)
+ifneq ($(IMPORT_LIB),$(FINAL_IMPORT_LIB))
+	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(IMPORT_LIB)) && ln -s $(notdir $(FINAL_IMPORT_LIB)) $(notdir $(IMPORT_LIB))
+endif
+ifneq ($(MIDDLE_IMPORT_LIB),$(FINAL_IMPORT_LIB))
+	cd $(DESTDIR)$(libdir) && $(RM) $(notdir $(MIDDLE_IMPORT_LIB)) && ln -s $(notdir $(FINAL_IMPORT_LIB)) $(notdir $(MIDDLE_IMPORT_LIB))
+endif
+endif
+
+install-headers:
+	$(MKINSTALLDIRS) $(DESTDIR)$(includedir)/unicode
+	@for file in $(HEADERS); do \
+	 echo "$(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/unicode"; \
+	 $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/unicode || exit; \
+	done
+
+dist-local:
+
+clean-local:
+	test -z "$(CLEANFILES)" || $(RMV) $(CLEANFILES)
+	$(RMV) $(OBJECTS) $(STATIC_OBJECTS) $(ALL_TARGETS) $(SO_VERSION_DATA)
+
+distclean-local: clean-local
+	$(RMV) Makefile
+
+check-local:
+
+Makefile: $(srcdir)/Makefile.in  $(top_builddir)/config.status
+	cd $(top_builddir) \
+	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
+
+ifneq ($(ENABLE_STATIC),)
+$(TARGET): $(TARGET)($(STATIC_OBJECTS))
+	$(RANLIB) $@
+endif
+
+ifneq ($(ENABLE_SHARED),)
+$(SHARED_OBJECT): $(OBJECTS) $(SO_VERSION_DATA)
+	$(SHLIB.cc) $(LD_SONAME) $(OUTOPT)$@ $^ $(LIBS)
+
+ifeq ($(OS390BATCH),1)
+$(BATCH_TARGET):$(OBJECTS)
+	$(SHLIB.cc) $(LD_SONAME) $(OUTOPT)$@ $^ $(BATCH_LIBS)
+endif   # OS390BATCH
+endif   # ENABLE_SHARED
+
+ifeq (,$(MAKECMDGOALS))
+-include $(DEPS)
+else
+ifneq ($(patsubst %clean,,$(MAKECMDGOALS)),)
+-include $(DEPS)
+endif
+endif
+


Property changes on: trunk/source/io/Makefile.in
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/locbund.c
===================================================================
--- trunk/source/io/locbund.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/locbund.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,187 +1,187 @@
-/*
-*******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-*******************************************************************************
-*
-* File locbund.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/18/98    stephen        Creation.
-*   12/10/1999  bobbyr(at)optiosoftware.com       Fix for memory leak + string allocation bugs
-*******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "locbund.h"
-
-#include "cmemory.h"
-#include "cstring.h"
-#include "ucln_io.h"
-#include "umutex.h"
-#include "unicode/ustring.h"
-#include "unicode/uloc.h"
-
-static UBool isFormatsInitialized = FALSE;
-static UNumberFormat *gPosixNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT];
-
-U_CDECL_BEGIN
-static UBool U_CALLCONV locbund_cleanup(void) {
-    int32_t style;
-    for (style = 0; style < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; style++) {
-        unum_close(gPosixNumberFormat[style]);
-        gPosixNumberFormat[style] = NULL;
-    }
-    isFormatsInitialized = FALSE;
-    return TRUE;
-}
-U_CDECL_END
-
-
-static U_INLINE UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) {
-    if (result->fNumberFormat[style-1] == NULL) {
-        UErrorCode status = U_ZERO_ERROR;
-        UBool needsInit;
-
-        UMTX_CHECK(NULL, gPosixNumberFormat[style-1] == NULL, needsInit);
-        if (needsInit) {
-            UNumberFormat *formatAlias = unum_open(style, NULL, 0, "en_US_POSIX", NULL, &status);
-
-            /* Cache upon first request. */
-            if (U_SUCCESS(status)) {
-                umtx_lock(NULL);
-                gPosixNumberFormat[style-1] = formatAlias;
-                ucln_io_registerCleanup(UCLN_IO_LOCBUND, locbund_cleanup);
-                umtx_unlock(NULL);
-            }
-        }
-
-        /* Copy the needed formatter. */
-        result->fNumberFormat[style-1] = unum_clone(gPosixNumberFormat[style-1], &status);
-    }
-    return result->fNumberFormat[style-1];
-}
-
-ULocaleBundle*        
-u_locbund_init(ULocaleBundle *result, const char *loc)
-{
-    int32_t len;
-
-    if(result == 0)
-        return 0;
-
-    if (loc == NULL) {
-        loc = uloc_getDefault();
-    }
-
-    uprv_memset(result, 0, sizeof(ULocaleBundle));
-
-    len = (int32_t)strlen(loc);
-    result->fLocale = (char*) uprv_malloc(len + 1);
-    if(result->fLocale == 0) {
-        return 0;
-    }
-
-    uprv_strcpy(result->fLocale, loc);
-
-    result->isInvariantLocale = uprv_strcmp(result->fLocale, "en_US_POSIX") == 0;
-
-    return result;
-}
-
-/*ULocaleBundle*        
-u_locbund_new(const char *loc)
-{
-    ULocaleBundle *result = (ULocaleBundle*) uprv_malloc(sizeof(ULocaleBundle));
-    return u_locbund_init(result, loc);
-}
-
-ULocaleBundle*
-u_locbund_clone(const ULocaleBundle *bundle)
-{
-    ULocaleBundle *result = (ULocaleBundle*)uprv_malloc(sizeof(ULocaleBundle));
-    UErrorCode status = U_ZERO_ERROR;
-    int32_t styleIdx;
-    
-    if(result == 0)
-        return 0;
-    
-    result->fLocale = (char*) uprv_malloc(strlen(bundle->fLocale) + 1);
-    if(result->fLocale == 0) {
-        uprv_free(result);
-        return 0;
-    }
-    
-    strcpy(result->fLocale, bundle->fLocale );
-    
-    for (styleIdx = 0; styleIdx < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; styleIdx++) {
-        status = U_ZERO_ERROR;
-        if (result->fNumberFormat[styleIdx]) {
-            result->fNumberFormat[styleIdx] = unum_clone(bundle->fNumberFormat[styleIdx], &status);
-            if (U_FAILURE(status)) {
-                result->fNumberFormat[styleIdx] = NULL;
-            }
-        }
-        else {
-            result->fNumberFormat[styleIdx] = NULL;
-        }
-    }
-    result->fDateFormat         = (bundle->fDateFormat == 0 ? 0 :
-        udat_clone(bundle->fDateFormat, &status));
-    result->fTimeFormat         = (bundle->fTimeFormat == 0 ? 0 :
-        udat_clone(bundle->fTimeFormat, &status));
-    
-    return result;
-}*/
-
-void
-u_locbund_close(ULocaleBundle *bundle)
-{
-    int32_t styleIdx;
-
-    uprv_free(bundle->fLocale);
-    
-    for (styleIdx = 0; styleIdx < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; styleIdx++) {
-        if (bundle->fNumberFormat[styleIdx]) {
-            unum_close(bundle->fNumberFormat[styleIdx]);
-        }
-    }
-    
-    uprv_memset(bundle, 0, sizeof(ULocaleBundle));
-/*    uprv_free(bundle);*/
-}
-
-UNumberFormat*
-u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style)
-{
-    UNumberFormat *formatAlias = NULL;
-    if (style >= UNUM_IGNORE) {
-        formatAlias = bundle->fNumberFormat[style-1];
-        if (formatAlias == NULL) {
-            if (bundle->isInvariantLocale) {
-                formatAlias = copyInvariantFormatter(bundle, style);
-            }
-            else {
-                UErrorCode status = U_ZERO_ERROR;
-                formatAlias = unum_open(style, NULL, 0, bundle->fLocale, NULL, &status);
-                if (U_FAILURE(status)) {
-                    unum_close(formatAlias);
-                    formatAlias = NULL;
-                }
-                else {
-                    bundle->fNumberFormat[style-1] = formatAlias;
-                }
-            }
-        }
-    }
-    return formatAlias;
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*
+* File locbund.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/18/98    stephen        Creation.
+*   12/10/1999  bobbyr(at)optiosoftware.com       Fix for memory leak + string allocation bugs
+*******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "locbund.h"
+
+#include "cmemory.h"
+#include "cstring.h"
+#include "ucln_io.h"
+#include "umutex.h"
+#include "unicode/ustring.h"
+#include "unicode/uloc.h"
+
+static UBool isFormatsInitialized = FALSE;
+static UNumberFormat *gPosixNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT];
+
+U_CDECL_BEGIN
+static UBool U_CALLCONV locbund_cleanup(void) {
+    int32_t style;
+    for (style = 0; style < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; style++) {
+        unum_close(gPosixNumberFormat[style]);
+        gPosixNumberFormat[style] = NULL;
+    }
+    isFormatsInitialized = FALSE;
+    return TRUE;
+}
+U_CDECL_END
+
+
+static U_INLINE UNumberFormat * copyInvariantFormatter(ULocaleBundle *result, UNumberFormatStyle style) {
+    if (result->fNumberFormat[style-1] == NULL) {
+        UErrorCode status = U_ZERO_ERROR;
+        UBool needsInit;
+
+        UMTX_CHECK(NULL, gPosixNumberFormat[style-1] == NULL, needsInit);
+        if (needsInit) {
+            UNumberFormat *formatAlias = unum_open(style, NULL, 0, "en_US_POSIX", NULL, &status);
+
+            /* Cache upon first request. */
+            if (U_SUCCESS(status)) {
+                umtx_lock(NULL);
+                gPosixNumberFormat[style-1] = formatAlias;
+                ucln_io_registerCleanup(UCLN_IO_LOCBUND, locbund_cleanup);
+                umtx_unlock(NULL);
+            }
+        }
+
+        /* Copy the needed formatter. */
+        result->fNumberFormat[style-1] = unum_clone(gPosixNumberFormat[style-1], &status);
+    }
+    return result->fNumberFormat[style-1];
+}
+
+ULocaleBundle*        
+u_locbund_init(ULocaleBundle *result, const char *loc)
+{
+    int32_t len;
+
+    if(result == 0)
+        return 0;
+
+    if (loc == NULL) {
+        loc = uloc_getDefault();
+    }
+
+    uprv_memset(result, 0, sizeof(ULocaleBundle));
+
+    len = (int32_t)strlen(loc);
+    result->fLocale = (char*) uprv_malloc(len + 1);
+    if(result->fLocale == 0) {
+        return 0;
+    }
+
+    uprv_strcpy(result->fLocale, loc);
+
+    result->isInvariantLocale = uprv_strcmp(result->fLocale, "en_US_POSIX") == 0;
+
+    return result;
+}
+
+/*ULocaleBundle*        
+u_locbund_new(const char *loc)
+{
+    ULocaleBundle *result = (ULocaleBundle*) uprv_malloc(sizeof(ULocaleBundle));
+    return u_locbund_init(result, loc);
+}
+
+ULocaleBundle*
+u_locbund_clone(const ULocaleBundle *bundle)
+{
+    ULocaleBundle *result = (ULocaleBundle*)uprv_malloc(sizeof(ULocaleBundle));
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t styleIdx;
+    
+    if(result == 0)
+        return 0;
+    
+    result->fLocale = (char*) uprv_malloc(strlen(bundle->fLocale) + 1);
+    if(result->fLocale == 0) {
+        uprv_free(result);
+        return 0;
+    }
+    
+    strcpy(result->fLocale, bundle->fLocale );
+    
+    for (styleIdx = 0; styleIdx < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; styleIdx++) {
+        status = U_ZERO_ERROR;
+        if (result->fNumberFormat[styleIdx]) {
+            result->fNumberFormat[styleIdx] = unum_clone(bundle->fNumberFormat[styleIdx], &status);
+            if (U_FAILURE(status)) {
+                result->fNumberFormat[styleIdx] = NULL;
+            }
+        }
+        else {
+            result->fNumberFormat[styleIdx] = NULL;
+        }
+    }
+    result->fDateFormat         = (bundle->fDateFormat == 0 ? 0 :
+        udat_clone(bundle->fDateFormat, &status));
+    result->fTimeFormat         = (bundle->fTimeFormat == 0 ? 0 :
+        udat_clone(bundle->fTimeFormat, &status));
+    
+    return result;
+}*/
+
+void
+u_locbund_close(ULocaleBundle *bundle)
+{
+    int32_t styleIdx;
+
+    uprv_free(bundle->fLocale);
+    
+    for (styleIdx = 0; styleIdx < ULOCALEBUNDLE_NUMBERFORMAT_COUNT; styleIdx++) {
+        if (bundle->fNumberFormat[styleIdx]) {
+            unum_close(bundle->fNumberFormat[styleIdx]);
+        }
+    }
+    
+    uprv_memset(bundle, 0, sizeof(ULocaleBundle));
+/*    uprv_free(bundle);*/
+}
+
+UNumberFormat*
+u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style)
+{
+    UNumberFormat *formatAlias = NULL;
+    if (style >= UNUM_IGNORE) {
+        formatAlias = bundle->fNumberFormat[style-1];
+        if (formatAlias == NULL) {
+            if (bundle->isInvariantLocale) {
+                formatAlias = copyInvariantFormatter(bundle, style);
+            }
+            else {
+                UErrorCode status = U_ZERO_ERROR;
+                formatAlias = unum_open(style, NULL, 0, bundle->fLocale, NULL, &status);
+                if (U_FAILURE(status)) {
+                    unum_close(formatAlias);
+                    formatAlias = NULL;
+                }
+                else {
+                    bundle->fNumberFormat[style-1] = formatAlias;
+                }
+            }
+        }
+    }
+    return formatAlias;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */


Property changes on: trunk/source/io/locbund.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/locbund.h
===================================================================
--- trunk/source/io/locbund.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/locbund.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,80 +1,80 @@
-/*
-*******************************************************************************
-*
-*   Copyright (C) 1998-2006s, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-*******************************************************************************
-*
-* File locbund.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   10/16/98    stephen     Creation.
-*   02/25/99    stephen     Modified for new C API.
-*******************************************************************************
-*/
-
-#ifndef LOCBUND_H
-#define LOCBUND_H
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/unum.h"
-
-#define ULOCALEBUNDLE_NUMBERFORMAT_COUNT ((int32_t)UNUM_SPELLOUT)
-
-typedef struct ULocaleBundle {
-    char            *fLocale;
-
-    UNumberFormat   *fNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT];
-    UBool           isInvariantLocale;
-} ULocaleBundle;
-
-
-/**
- * Initialize a ULocaleBundle, initializing all formatters to 0.
- * @param result A ULocaleBundle to initialize.
- * @param loc The locale of the ULocaleBundle.
- * @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
- */
-ULocaleBundle* 
-u_locbund_init(ULocaleBundle *result, const char *loc);
-
-/**
- * Create a new ULocaleBundle, initializing all formatters to 0.
- * @param loc The locale of the ULocaleBundle.
- * @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
- */
-/*ULocaleBundle*
-u_locbund_new(const char *loc);*/
-
-/**
- * Create a deep copy of this ULocaleBundle;
- * @param bundle The ULocaleBundle to clone.
- * @return A new ULocaleBundle.
- */
-/*ULocaleBundle*
-u_locbund_clone(const ULocaleBundle *bundle);*/
-
-/**
- * Delete the specified ULocaleBundle, freeing all associated memory.
- * @param bundle The ULocaleBundle to delete
- */
-void
-u_locbund_close(ULocaleBundle *bundle);
-
-/**
- * Get the NumberFormat used to format and parse numbers in a ULocaleBundle.
- * @param bundle The ULocaleBundle to use
- * @return A pointer to the NumberFormat used for number formatting and parsing.
- */
-UNumberFormat*        
-u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style);
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
-#endif
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1998-2006s, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*
+* File locbund.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   10/16/98    stephen     Creation.
+*   02/25/99    stephen     Modified for new C API.
+*******************************************************************************
+*/
+
+#ifndef LOCBUND_H
+#define LOCBUND_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/unum.h"
+
+#define ULOCALEBUNDLE_NUMBERFORMAT_COUNT ((int32_t)UNUM_SPELLOUT)
+
+typedef struct ULocaleBundle {
+    char            *fLocale;
+
+    UNumberFormat   *fNumberFormat[ULOCALEBUNDLE_NUMBERFORMAT_COUNT];
+    UBool           isInvariantLocale;
+} ULocaleBundle;
+
+
+/**
+ * Initialize a ULocaleBundle, initializing all formatters to 0.
+ * @param result A ULocaleBundle to initialize.
+ * @param loc The locale of the ULocaleBundle.
+ * @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
+ */
+ULocaleBundle* 
+u_locbund_init(ULocaleBundle *result, const char *loc);
+
+/**
+ * Create a new ULocaleBundle, initializing all formatters to 0.
+ * @param loc The locale of the ULocaleBundle.
+ * @return A pointer to a ULocaleBundle, or 0 if <TT>loc</TT> was invalid.
+ */
+/*ULocaleBundle*
+u_locbund_new(const char *loc);*/
+
+/**
+ * Create a deep copy of this ULocaleBundle;
+ * @param bundle The ULocaleBundle to clone.
+ * @return A new ULocaleBundle.
+ */
+/*ULocaleBundle*
+u_locbund_clone(const ULocaleBundle *bundle);*/
+
+/**
+ * Delete the specified ULocaleBundle, freeing all associated memory.
+ * @param bundle The ULocaleBundle to delete
+ */
+void
+u_locbund_close(ULocaleBundle *bundle);
+
+/**
+ * Get the NumberFormat used to format and parse numbers in a ULocaleBundle.
+ * @param bundle The ULocaleBundle to use
+ * @return A pointer to the NumberFormat used for number formatting and parsing.
+ */
+UNumberFormat*        
+u_locbund_getNumberFormat(ULocaleBundle *bundle, UNumberFormatStyle style);
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif


Property changes on: trunk/source/io/locbund.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/sprintf.c
===================================================================
--- trunk/source/io/sprintf.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/sprintf.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,250 +1,250 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 2001-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File sprintf.c
-*
-* Modification History:
-*
-*   Date        Name            Description
-*   02/08/2001  george          Creation. Copied from uprintf.c
-*   03/27/2002  Mark Schneckloth Many fixes regarding alignment, null termination
-*       (mschneckloth at atomz.com) and other various problems.
-*   08/07/2003  george          Reunify printf implementations
-*******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "unicode/putil.h"
-
-#include "uprintf.h"
-#include "locbund.h"
-
-#include "cmemory.h"
-#include <ctype.h>
-
-/* u_minstrncpy copies the minimum number of code units of (count or output->available) */
-static int32_t
-u_sprintf_write(void        *context,
-                const UChar *str,
-                int32_t     count)
-{
-    u_localized_print_string *output = (u_localized_print_string *)context;
-    int32_t size = ufmt_min(count, output->available);
-
-    u_strncpy(output->str + (output->len - output->available), str, size);
-    output->available -= size;
-    return size;
-}
-
-static int32_t
-u_sprintf_pad_and_justify(void                        *context,
-                          const u_printf_spec_info    *info,
-                          const UChar                 *result,
-                          int32_t                     resultLen)
-{
-    u_localized_print_string *output = (u_localized_print_string *)context;
-    int32_t written = 0;
-
-    resultLen = ufmt_min(resultLen, output->available);
-
-    /* pad and justify, if needed */
-    if(info->fWidth != -1 && resultLen < info->fWidth) {
-        int32_t paddingLeft = info->fWidth - resultLen;
-        int32_t outputPos = output->len - output->available;
-  
-        if (paddingLeft + resultLen > output->available) {
-            paddingLeft = output->available - resultLen;
-            if (paddingLeft < 0) {
-                paddingLeft = 0;
-            }
-            /* paddingLeft = output->available - resultLen;*/
-        }
-        written += paddingLeft;
-
-        /* left justify */
-        if(info->fLeft) {
-            written += u_sprintf_write(output, result, resultLen);
-            u_memset(&output->str[outputPos + resultLen], info->fPadChar, paddingLeft);
-            output->available -= paddingLeft;
-        }
-        /* right justify */
-        else {
-            u_memset(&output->str[outputPos], info->fPadChar, paddingLeft);
-            output->available -= paddingLeft;
-            written += u_sprintf_write(output, result, resultLen);
-        }
-    }
-    /* just write the formatted output */
-    else {
-        written = u_sprintf_write(output, result, resultLen);
-    }
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2
-u_sprintf(UChar       *buffer,
-          const char    *patternSpecification,
-          ... )
-{
-    va_list ap;
-    int32_t written;
-
-    va_start(ap, patternSpecification);
-    written = u_vsnprintf(buffer, INT32_MAX, patternSpecification, ap);
-    va_end(ap);
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2
-u_sprintf_u(UChar     *buffer,
-            const UChar    *patternSpecification,
-            ... )
-{
-    va_list ap;
-    int32_t written;
-
-    va_start(ap, patternSpecification);
-    written = u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap);
-    va_end(ap);
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsprintf(UChar       *buffer,
-           const char     *patternSpecification,
-           va_list         ap)
-{
-    return u_vsnprintf(buffer, INT32_MAX, patternSpecification, ap);
-}
-
-U_CAPI int32_t U_EXPORT2
-u_snprintf(UChar       *buffer,
-           int32_t         count,
-           const char    *patternSpecification,
-           ... )
-{
-    va_list ap;
-    int32_t written;
-
-    va_start(ap, patternSpecification);
-    written = u_vsnprintf(buffer, count, patternSpecification, ap);
-    va_end(ap);
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2
-u_snprintf_u(UChar     *buffer,
-             int32_t        count,
-             const UChar    *patternSpecification,
-             ... )
-{
-    va_list ap;
-    int32_t written;
-
-    va_start(ap, patternSpecification);
-    written = u_vsnprintf_u(buffer, count, patternSpecification, ap);
-    va_end(ap);
-
-    return written;
-}
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsnprintf(UChar       *buffer,
-            int32_t         count,
-            const char     *patternSpecification,
-            va_list         ap)
-{
-    int32_t written;
-    UChar *pattern;
-    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
-    int32_t size = (int32_t)strlen(patternSpecification) + 1;
-
-    /* convert from the default codepage to Unicode */
-    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
-        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
-        if(pattern == 0) {
-            return 0;
-        }
-    }
-    else {
-        pattern = patBuffer;
-    }
-    u_charsToUChars(patternSpecification, pattern, size);
-
-    /* do the work */
-    written = u_vsnprintf_u(buffer, count, pattern, ap);
-
-    /* clean up */
-    if (pattern != patBuffer) {
-        uprv_free(pattern);
-    }
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2 
-u_vsprintf_u(UChar       *buffer, 
-             const UChar *patternSpecification, 
-             va_list     ap) 
-{ 
-    return u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap); 
-} 
-
-static const u_printf_stream_handler g_sprintf_stream_handler = {
-    u_sprintf_write,
-    u_sprintf_pad_and_justify
-};
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsnprintf_u(UChar    *buffer,
-              int32_t        count,
-              const UChar    *patternSpecification,
-              va_list        ap)
-{
-    int32_t          written = 0;   /* haven't written anything yet */
-
-    u_localized_print_string outStr;
-
-    if (count < 0) {
-        count = INT32_MAX;
-    }
-
-    outStr.str = buffer;
-    outStr.len = count;
-    outStr.available = count;
-
-    if(u_locbund_init(&outStr.fBundle, "en_US_POSIX") == 0) {
-        return 0;
-    }
-
-    /* parse and print the whole format string */
-    u_printf_parse(&g_sprintf_stream_handler, patternSpecification, &outStr, &outStr, &outStr.fBundle, &written, ap);
-
-    /* Terminate the buffer, if there's room. */
-    if (outStr.available > 0) {
-        buffer[outStr.len - outStr.available] = 0x0000;
-    }
-
-    /* Release the cloned bundle, if we cloned it. */
-    u_locbund_close(&outStr.fBundle);
-
-    /* return # of UChars written */
-    return written;
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 2001-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File sprintf.c
+*
+* Modification History:
+*
+*   Date        Name            Description
+*   02/08/2001  george          Creation. Copied from uprintf.c
+*   03/27/2002  Mark Schneckloth Many fixes regarding alignment, null termination
+*       (mschneckloth at atomz.com) and other various problems.
+*   08/07/2003  george          Reunify printf implementations
+*******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "unicode/putil.h"
+
+#include "uprintf.h"
+#include "locbund.h"
+
+#include "cmemory.h"
+#include <ctype.h>
+
+/* u_minstrncpy copies the minimum number of code units of (count or output->available) */
+static int32_t
+u_sprintf_write(void        *context,
+                const UChar *str,
+                int32_t     count)
+{
+    u_localized_print_string *output = (u_localized_print_string *)context;
+    int32_t size = ufmt_min(count, output->available);
+
+    u_strncpy(output->str + (output->len - output->available), str, size);
+    output->available -= size;
+    return size;
+}
+
+static int32_t
+u_sprintf_pad_and_justify(void                        *context,
+                          const u_printf_spec_info    *info,
+                          const UChar                 *result,
+                          int32_t                     resultLen)
+{
+    u_localized_print_string *output = (u_localized_print_string *)context;
+    int32_t written = 0;
+
+    resultLen = ufmt_min(resultLen, output->available);
+
+    /* pad and justify, if needed */
+    if(info->fWidth != -1 && resultLen < info->fWidth) {
+        int32_t paddingLeft = info->fWidth - resultLen;
+        int32_t outputPos = output->len - output->available;
+  
+        if (paddingLeft + resultLen > output->available) {
+            paddingLeft = output->available - resultLen;
+            if (paddingLeft < 0) {
+                paddingLeft = 0;
+            }
+            /* paddingLeft = output->available - resultLen;*/
+        }
+        written += paddingLeft;
+
+        /* left justify */
+        if(info->fLeft) {
+            written += u_sprintf_write(output, result, resultLen);
+            u_memset(&output->str[outputPos + resultLen], info->fPadChar, paddingLeft);
+            output->available -= paddingLeft;
+        }
+        /* right justify */
+        else {
+            u_memset(&output->str[outputPos], info->fPadChar, paddingLeft);
+            output->available -= paddingLeft;
+            written += u_sprintf_write(output, result, resultLen);
+        }
+    }
+    /* just write the formatted output */
+    else {
+        written = u_sprintf_write(output, result, resultLen);
+    }
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2
+u_sprintf(UChar       *buffer,
+          const char    *patternSpecification,
+          ... )
+{
+    va_list ap;
+    int32_t written;
+
+    va_start(ap, patternSpecification);
+    written = u_vsnprintf(buffer, INT32_MAX, patternSpecification, ap);
+    va_end(ap);
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2
+u_sprintf_u(UChar     *buffer,
+            const UChar    *patternSpecification,
+            ... )
+{
+    va_list ap;
+    int32_t written;
+
+    va_start(ap, patternSpecification);
+    written = u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap);
+    va_end(ap);
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vsprintf(UChar       *buffer,
+           const char     *patternSpecification,
+           va_list         ap)
+{
+    return u_vsnprintf(buffer, INT32_MAX, patternSpecification, ap);
+}
+
+U_CAPI int32_t U_EXPORT2
+u_snprintf(UChar       *buffer,
+           int32_t         count,
+           const char    *patternSpecification,
+           ... )
+{
+    va_list ap;
+    int32_t written;
+
+    va_start(ap, patternSpecification);
+    written = u_vsnprintf(buffer, count, patternSpecification, ap);
+    va_end(ap);
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2
+u_snprintf_u(UChar     *buffer,
+             int32_t        count,
+             const UChar    *patternSpecification,
+             ... )
+{
+    va_list ap;
+    int32_t written;
+
+    va_start(ap, patternSpecification);
+    written = u_vsnprintf_u(buffer, count, patternSpecification, ap);
+    va_end(ap);
+
+    return written;
+}
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vsnprintf(UChar       *buffer,
+            int32_t         count,
+            const char     *patternSpecification,
+            va_list         ap)
+{
+    int32_t written;
+    UChar *pattern;
+    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+    int32_t size = (int32_t)strlen(patternSpecification) + 1;
+
+    /* convert from the default codepage to Unicode */
+    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
+        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+        if(pattern == 0) {
+            return 0;
+        }
+    }
+    else {
+        pattern = patBuffer;
+    }
+    u_charsToUChars(patternSpecification, pattern, size);
+
+    /* do the work */
+    written = u_vsnprintf_u(buffer, count, pattern, ap);
+
+    /* clean up */
+    if (pattern != patBuffer) {
+        uprv_free(pattern);
+    }
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2 
+u_vsprintf_u(UChar       *buffer, 
+             const UChar *patternSpecification, 
+             va_list     ap) 
+{ 
+    return u_vsnprintf_u(buffer, INT32_MAX, patternSpecification, ap); 
+} 
+
+static const u_printf_stream_handler g_sprintf_stream_handler = {
+    u_sprintf_write,
+    u_sprintf_pad_and_justify
+};
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vsnprintf_u(UChar    *buffer,
+              int32_t        count,
+              const UChar    *patternSpecification,
+              va_list        ap)
+{
+    int32_t          written = 0;   /* haven't written anything yet */
+
+    u_localized_print_string outStr;
+
+    if (count < 0) {
+        count = INT32_MAX;
+    }
+
+    outStr.str = buffer;
+    outStr.len = count;
+    outStr.available = count;
+
+    if(u_locbund_init(&outStr.fBundle, "en_US_POSIX") == 0) {
+        return 0;
+    }
+
+    /* parse and print the whole format string */
+    u_printf_parse(&g_sprintf_stream_handler, patternSpecification, &outStr, &outStr, &outStr.fBundle, &written, ap);
+
+    /* Terminate the buffer, if there's room. */
+    if (outStr.available > 0) {
+        buffer[outStr.len - outStr.available] = 0x0000;
+    }
+
+    /* Release the cloned bundle, if we cloned it. */
+    u_locbund_close(&outStr.fBundle);
+
+    /* return # of UChars written */
+    return written;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+


Property changes on: trunk/source/io/sprintf.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/sscanf.c
===================================================================
--- trunk/source/io/sscanf.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/sscanf.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,128 +1,128 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 2000-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File sscanf.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   02/08/00    george      Creation. Copied from uscanf.c
-******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/putil.h"
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "uscanf.h"
-#include "ufile.h"
-#include "ufmt_cmn.h"
-
-#include "cmemory.h"
-#include "cstring.h"
-
-
-U_CAPI int32_t U_EXPORT2
-u_sscanf(const UChar   *buffer,
-         const char    *patternSpecification,
-         ... )
-{
-    va_list ap;
-    int32_t converted;
-
-    va_start(ap, patternSpecification);
-    converted = u_vsscanf(buffer, patternSpecification, ap);
-    va_end(ap);
-
-    return converted;
-}
-
-U_CAPI int32_t U_EXPORT2
-u_sscanf_u(const UChar    *buffer,
-           const UChar    *patternSpecification,
-           ... )
-{
-    va_list ap;
-    int32_t converted;
-
-    va_start(ap, patternSpecification);
-    converted = u_vsscanf_u(buffer, patternSpecification, ap);
-    va_end(ap);
-
-    return converted;
-}
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsscanf(const UChar   *buffer,
-          const char    *patternSpecification,
-          va_list        ap)
-{
-    int32_t converted;
-    UChar *pattern;
-    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
-    int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
-
-    /* convert from the default codepage to Unicode */
-    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
-        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
-        if(pattern == 0) {
-            return 0;
-        }
-    }
-    else {
-        pattern = patBuffer;
-    }
-    u_charsToUChars(patternSpecification, pattern, size);
-
-    /* do the work */
-    converted = u_vsscanf_u(buffer, pattern, ap);
-
-    /* clean up */
-    if (pattern != patBuffer) {
-        uprv_free(pattern);
-    }
-
-    return converted;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vsscanf_u(const UChar *buffer,
-            const UChar *patternSpecification,
-            va_list     ap)
-{
-    int32_t         converted;
-    UFILE           inStr;
-
-    inStr.fConverter = NULL;
-    inStr.fFile = NULL;
-    inStr.fOwnFile = FALSE;
-#if !UCONFIG_NO_TRANSLITERATION
-    inStr.fTranslit = NULL;
-#endif
-    inStr.fUCBuffer[0] = 0;
-    inStr.str.fBuffer = (UChar *)buffer;
-    inStr.str.fPos = (UChar *)buffer;
-    inStr.str.fLimit = buffer + u_strlen(buffer);
-
-    if(u_locbund_init(&inStr.str.fBundle, "en_US_POSIX") == 0) {
-        return 0;
-    }
-
-    converted = u_scanf_parse(&inStr, patternSpecification, ap);
-
-    u_locbund_close(&inStr.str.fBundle);
-
-    /* return # of items converted */
-    return converted;
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 2000-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File sscanf.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   02/08/00    george      Creation. Copied from uscanf.c
+******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/putil.h"
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "uscanf.h"
+#include "ufile.h"
+#include "ufmt_cmn.h"
+
+#include "cmemory.h"
+#include "cstring.h"
+
+
+U_CAPI int32_t U_EXPORT2
+u_sscanf(const UChar   *buffer,
+         const char    *patternSpecification,
+         ... )
+{
+    va_list ap;
+    int32_t converted;
+
+    va_start(ap, patternSpecification);
+    converted = u_vsscanf(buffer, patternSpecification, ap);
+    va_end(ap);
+
+    return converted;
+}
+
+U_CAPI int32_t U_EXPORT2
+u_sscanf_u(const UChar    *buffer,
+           const UChar    *patternSpecification,
+           ... )
+{
+    va_list ap;
+    int32_t converted;
+
+    va_start(ap, patternSpecification);
+    converted = u_vsscanf_u(buffer, patternSpecification, ap);
+    va_end(ap);
+
+    return converted;
+}
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vsscanf(const UChar   *buffer,
+          const char    *patternSpecification,
+          va_list        ap)
+{
+    int32_t converted;
+    UChar *pattern;
+    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+    int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
+
+    /* convert from the default codepage to Unicode */
+    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
+        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+        if(pattern == 0) {
+            return 0;
+        }
+    }
+    else {
+        pattern = patBuffer;
+    }
+    u_charsToUChars(patternSpecification, pattern, size);
+
+    /* do the work */
+    converted = u_vsscanf_u(buffer, pattern, ap);
+
+    /* clean up */
+    if (pattern != patBuffer) {
+        uprv_free(pattern);
+    }
+
+    return converted;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vsscanf_u(const UChar *buffer,
+            const UChar *patternSpecification,
+            va_list     ap)
+{
+    int32_t         converted;
+    UFILE           inStr;
+
+    inStr.fConverter = NULL;
+    inStr.fFile = NULL;
+    inStr.fOwnFile = FALSE;
+#if !UCONFIG_NO_TRANSLITERATION
+    inStr.fTranslit = NULL;
+#endif
+    inStr.fUCBuffer[0] = 0;
+    inStr.str.fBuffer = (UChar *)buffer;
+    inStr.str.fPos = (UChar *)buffer;
+    inStr.str.fLimit = buffer + u_strlen(buffer);
+
+    if(u_locbund_init(&inStr.str.fBundle, "en_US_POSIX") == 0) {
+        return 0;
+    }
+
+    converted = u_scanf_parse(&inStr, patternSpecification, ap);
+
+    u_locbund_close(&inStr.str.fBundle);
+
+    /* return # of items converted */
+    return converted;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+


Property changes on: trunk/source/io/sscanf.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ucln_io.c
===================================================================
--- trunk/source/io/ucln_io.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ucln_io.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,51 +1,51 @@
-/*
-******************************************************************************
-*                                                                            *
-* Copyright (C) 2001-2006, International Business Machines                   *
-*                Corporation and others. All Rights Reserved.                *
-*                                                                            *
-******************************************************************************
-*   file name:  ucln_io.c
-*   encoding:   US-ASCII
-*   tab size:   8 (not used)
-*   indentation:4
-*
-*   created on: 2006August11
-*   created by: George Rhoten
-*/
-
-#include "ucln.h"
-#include "ucln_io.h"
-#include "umutex.h"
-#include "uassert.h"
-
-/* Leave this copyright notice here! It needs to go somewhere in this library. */
-static const char copyright[] = U_COPYRIGHT_STRING;
-
-static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT];
-
-static UBool io_cleanup(void)
-{
-    ECleanupIOType libType = UCLN_IO_START;
-
-    while (++libType<UCLN_IO_COUNT) {
-        if (gCleanupFunctions[libType])
-        {
-            gCleanupFunctions[libType]();
-            gCleanupFunctions[libType] = NULL;
-        }
-    }
-    return TRUE;
-}
-
-void ucln_io_registerCleanup(ECleanupIOType type,
-                               cleanupFunc *func)
-{
-    U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT);
-    ucln_registerCleanup(UCLN_IO, io_cleanup);
-    if (UCLN_IO_START < type && type < UCLN_IO_COUNT)
-    {
-        gCleanupFunctions[type] = func;
-    }
-}
-
+/*
+******************************************************************************
+*                                                                            *
+* Copyright (C) 2001-2006, International Business Machines                   *
+*                Corporation and others. All Rights Reserved.                *
+*                                                                            *
+******************************************************************************
+*   file name:  ucln_io.c
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2006August11
+*   created by: George Rhoten
+*/
+
+#include "ucln.h"
+#include "ucln_io.h"
+#include "umutex.h"
+#include "uassert.h"
+
+/* Leave this copyright notice here! It needs to go somewhere in this library. */
+static const char copyright[] = U_COPYRIGHT_STRING;
+
+static cleanupFunc *gCleanupFunctions[UCLN_IO_COUNT];
+
+static UBool io_cleanup(void)
+{
+    ECleanupIOType libType = UCLN_IO_START;
+
+    while (++libType<UCLN_IO_COUNT) {
+        if (gCleanupFunctions[libType])
+        {
+            gCleanupFunctions[libType]();
+            gCleanupFunctions[libType] = NULL;
+        }
+    }
+    return TRUE;
+}
+
+void ucln_io_registerCleanup(ECleanupIOType type,
+                               cleanupFunc *func)
+{
+    U_ASSERT(UCLN_IO_START < type && type < UCLN_IO_COUNT);
+    ucln_registerCleanup(UCLN_IO, io_cleanup);
+    if (UCLN_IO_START < type && type < UCLN_IO_COUNT)
+    {
+        gCleanupFunctions[type] = func;
+    }
+}
+


Property changes on: trunk/source/io/ucln_io.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ucln_io.h
===================================================================
--- trunk/source/io/ucln_io.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ucln_io.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,37 +1,37 @@
-/*
-******************************************************************************
-*                                                                            *
-* Copyright (C) 2001-2006, International Business Machines                   *
-*                Corporation and others. All Rights Reserved.                *
-*                                                                            *
-******************************************************************************
-*   file name:  ucln_io.h
-*   encoding:   US-ASCII
-*   tab size:   8 (not used)
-*   indentation:4
-*
-*   created on: 2006August11
-*   created by: George Rhoten
-*/
-
-#ifndef __UCLN_IO_H__
-#define __UCLN_IO_H__
-
-#include "unicode/utypes.h"
-#include "ucln.h"
-
-/*
-Please keep the order of enums declared in same order
-as the functions are suppose to be called. */
-typedef enum ECleanupIOType {
-    UCLN_IO_START = -1,
-    UCLN_IO_LOCBUND,
-    UCLN_IO_COUNT /* This must be last */
-} ECleanupIOType;
-
-/* Main library cleanup registration function. */
-/* See common/ucln.h for details on adding a cleanup function. */
-U_CFUNC void U_EXPORT2 ucln_io_registerCleanup(ECleanupIOType type,
-                                                 cleanupFunc *func);
-
-#endif
+/*
+******************************************************************************
+*                                                                            *
+* Copyright (C) 2001-2006, International Business Machines                   *
+*                Corporation and others. All Rights Reserved.                *
+*                                                                            *
+******************************************************************************
+*   file name:  ucln_io.h
+*   encoding:   US-ASCII
+*   tab size:   8 (not used)
+*   indentation:4
+*
+*   created on: 2006August11
+*   created by: George Rhoten
+*/
+
+#ifndef __UCLN_IO_H__
+#define __UCLN_IO_H__
+
+#include "unicode/utypes.h"
+#include "ucln.h"
+
+/*
+Please keep the order of enums declared in same order
+as the functions are suppose to be called. */
+typedef enum ECleanupIOType {
+    UCLN_IO_START = -1,
+    UCLN_IO_LOCBUND,
+    UCLN_IO_COUNT /* This must be last */
+} ECleanupIOType;
+
+/* Main library cleanup registration function. */
+/* See common/ucln.h for details on adding a cleanup function. */
+U_CFUNC void U_EXPORT2 ucln_io_registerCleanup(ECleanupIOType type,
+                                                 cleanupFunc *func);
+
+#endif


Property changes on: trunk/source/io/ucln_io.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ufile.c
===================================================================
--- trunk/source/io/ufile.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ufile.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,286 +1,286 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File ufile.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/19/98    stephen     Creation.
-*   03/12/99    stephen     Modified for new C API.
-*   06/16/99    stephen     Changed T_LocaleBundle to u_locbund
-*   07/19/99    stephen     Fixed to use ucnv's default codepage.
-******************************************************************************
-*/
-
-/* define for fileno.  */
-#ifndef _XOPEN_SOURCE
-#if __STDC_VERSION__ >= 199901L
-/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 */
-#define _XOPEN_SOURCE 600
-#else
-#define _XOPEN_SOURCE 4
-#endif
-#endif
-
-#include "locmap.h"
-#include "unicode/ustdio.h"
-#include "ufile.h"
-#include "unicode/uloc.h"
-#include "unicode/ures.h"
-#include "unicode/ucnv.h"
-#include "cstring.h"
-#include "cmemory.h"
-
-#if defined(U_WINDOWS) && !defined(fileno)
-/* Windows likes to rename Unix-like functions */
-#define fileno _fileno
-#endif
-
-U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_finit(FILE        *f,
-        const char    *locale,
-        const char    *codepage)
-{
-    UErrorCode status = U_ZERO_ERROR;
-    UFILE     *result;
-    if(f == NULL) {
-        return 0;
-    }
-    result = (UFILE*) uprv_malloc(sizeof(UFILE));
-    if(result == NULL) {
-        return 0;
-    }
-
-    uprv_memset(result, 0, sizeof(UFILE));
-    result->fFileno = fileno(f);
-
-#if defined(U_WINDOWS) && !defined(__BORLANDC__)
-    if (0 <= result->fFileno && result->fFileno <= 2) {
-        /* stdin, stdout and stderr need to be special cased for Windows 98 */
-#if _MSC_VER >= 1400
-        result->fFile = &__iob_func()[_fileno(f)];
-#else
-        result->fFile = &_iob[_fileno(f)];
-#endif
-    }
-    else
-#endif
-    {
-        result->fFile = f;
-    }
-
-    result->str.fBuffer = result->fUCBuffer;
-    result->str.fPos    = result->fUCBuffer;
-    result->str.fLimit  = result->fUCBuffer;
-
-#if !UCONFIG_NO_FORMATTING
-        /* if locale is 0, use the default */
-        if(u_locbund_init(&result->str.fBundle, locale) == 0) {
-            /* DO NOT FCLOSE HERE! */
-            uprv_free(result);
-            return 0;
-        }
-#endif
-
-    /* If the codepage is not "" use the ucnv_open default behavior */
-    if(codepage == NULL || *codepage != '\0') {
-        result->fConverter = ucnv_open(codepage, &status);
-    }
-    /* else result->fConverter is already memset'd to NULL. */
-
-    if(U_FAILURE(status)) {
-#if !UCONFIG_NO_FORMATTING
-        u_locbund_close(&result->str.fBundle);
-#endif
-        /* DO NOT fclose here!!!!!! */
-        uprv_free(result);
-        result = NULL;
-    }
-
-    return result;
-}
-
-U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fopen(const char    *filename,
-        const char    *perm,
-        const char    *locale,
-        const char    *codepage)
-{
-    UFILE     *result;
-    FILE     *systemFile = fopen(filename, perm);
-    if(systemFile == 0) {
-        return 0;
-    }
-
-    result = u_finit(systemFile, locale, codepage);
-
-    if (result) {
-        result->fOwnFile = TRUE;
-    }
-    else {
-        /* Something bad happened.
-           Maybe the converter couldn't be opened. */
-        fclose(systemFile);
-    }
-
-    return result;
-}
-
-U_CAPI UFILE* U_EXPORT2
-u_fstropen(UChar *stringBuf,
-           int32_t      capacity,
-           const char  *locale)
-{
-    UFILE *result;
-
-    if (capacity < 0) {
-        return NULL;
-    }
-
-    result = (UFILE*) uprv_malloc(sizeof(UFILE));
-    uprv_memset(result, 0, sizeof(UFILE));
-    result->str.fBuffer = stringBuf;
-    result->str.fPos    = stringBuf;
-    result->str.fLimit  = stringBuf+capacity;
-
-#if !UCONFIG_NO_FORMATTING
-    /* if locale is 0, use the default */
-    if(u_locbund_init(&result->str.fBundle, locale) == 0) {
-        /* DO NOT FCLOSE HERE! */
-        uprv_free(result);
-        return 0;
-    }
-#endif
-
-    return result;
-}
-
-U_CAPI UBool U_EXPORT2
-u_feof(UFILE  *f)
-{
-    UBool endOfBuffer;
-    if (f == NULL) {
-        return TRUE;
-    }
-    endOfBuffer = (UBool)(f->str.fPos >= f->str.fLimit);
-    if (f->fFile != NULL) {
-        return endOfBuffer && feof(f->fFile);
-    }
-    return endOfBuffer;
-}
-
-U_CAPI void U_EXPORT2
-u_fflush(UFILE *file)
-{
-    ufile_flush_translit(file);
-    if (file->fFile) {
-        fflush(file->fFile);
-    }
-    else if (file->str.fPos < file->str.fLimit) {
-        *(file->str.fPos++) = 0;
-    }
-    /* TODO: flush input */
-}
-
-U_CAPI void
-u_frewind(UFILE *file)
-{
-    u_fflush(file);
-    ucnv_reset(file->fConverter);
-    if (file->fFile) {
-        rewind(file->fFile);
-        file->str.fLimit = file->fUCBuffer;
-        file->str.fPos   = file->fUCBuffer;
-    }
-    else {
-        file->str.fPos = file->str.fBuffer;
-    }
-}
-
-U_CAPI void U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fclose(UFILE *file)
-{
-    u_fflush(file);
-    ufile_close_translit(file);
-
-    if(file->fOwnFile)
-        fclose(file->fFile);
-
-#if !UCONFIG_NO_FORMATTING
-    u_locbund_close(&file->str.fBundle);
-#endif
-
-    ucnv_close(file->fConverter);
-    uprv_free(file);
-}
-
-U_CAPI FILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetfile(    UFILE         *f)
-{
-    return f->fFile;
-}
-
-#if !UCONFIG_NO_FORMATTING
-
-U_CAPI const char*  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetlocale(    UFILE        *file)
-{
-    return file->str.fBundle.fLocale;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fsetlocale(UFILE      *file,
-             const char *locale)
-{
-    u_locbund_close(&file->str.fBundle);
-
-    return u_locbund_init(&file->str.fBundle, locale) == 0 ? -1 : 0;
-}
-
-#endif
-
-U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetcodepage(UFILE        *file)
-{
-    UErrorCode     status = U_ZERO_ERROR;
-    const char     *codepage = NULL;
-
-    if (file->fConverter) {
-        codepage = ucnv_getName(file->fConverter, &status);
-        if(U_FAILURE(status))
-            return 0;
-    }
-    return codepage;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fsetcodepage(    const char    *codepage,
-               UFILE        *file)
-{
-    UErrorCode status = U_ZERO_ERROR;
-    int32_t retVal = -1;
-
-    /* We use the normal default codepage for this system, and not the one for the locale. */
-    if ((file->str.fPos == file->str.fBuffer) && (file->str.fLimit == file->str.fBuffer)) {
-        ucnv_close(file->fConverter);
-        file->fConverter = ucnv_open(codepage, &status);
-        if(U_SUCCESS(status)) {
-            retVal = 0;
-        }
-    }
-    return retVal;
-}
-
-
-U_CAPI UConverter * U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetConverter(UFILE *file)
-{
-    return file->fConverter;
-}
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ufile.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/19/98    stephen     Creation.
+*   03/12/99    stephen     Modified for new C API.
+*   06/16/99    stephen     Changed T_LocaleBundle to u_locbund
+*   07/19/99    stephen     Fixed to use ucnv's default codepage.
+******************************************************************************
+*/
+
+/* define for fileno.  */
+#ifndef _XOPEN_SOURCE
+#if __STDC_VERSION__ >= 199901L
+/* It is invalid to compile an XPG3, XPG4, XPG4v2 or XPG5 application using c99 */
+#define _XOPEN_SOURCE 600
+#else
+#define _XOPEN_SOURCE 4
+#endif
+#endif
+
+#include "locmap.h"
+#include "unicode/ustdio.h"
+#include "ufile.h"
+#include "unicode/uloc.h"
+#include "unicode/ures.h"
+#include "unicode/ucnv.h"
+#include "cstring.h"
+#include "cmemory.h"
+
+#if defined(U_WINDOWS) && !defined(fileno)
+/* Windows likes to rename Unix-like functions */
+#define fileno _fileno
+#endif
+
+U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_finit(FILE        *f,
+        const char    *locale,
+        const char    *codepage)
+{
+    UErrorCode status = U_ZERO_ERROR;
+    UFILE     *result;
+    if(f == NULL) {
+        return 0;
+    }
+    result = (UFILE*) uprv_malloc(sizeof(UFILE));
+    if(result == NULL) {
+        return 0;
+    }
+
+    uprv_memset(result, 0, sizeof(UFILE));
+    result->fFileno = fileno(f);
+
+#if defined(U_WINDOWS) && !defined(__BORLANDC__)
+    if (0 <= result->fFileno && result->fFileno <= 2) {
+        /* stdin, stdout and stderr need to be special cased for Windows 98 */
+#if _MSC_VER >= 1400
+        result->fFile = &__iob_func()[_fileno(f)];
+#else
+        result->fFile = &_iob[_fileno(f)];
+#endif
+    }
+    else
+#endif
+    {
+        result->fFile = f;
+    }
+
+    result->str.fBuffer = result->fUCBuffer;
+    result->str.fPos    = result->fUCBuffer;
+    result->str.fLimit  = result->fUCBuffer;
+
+#if !UCONFIG_NO_FORMATTING
+        /* if locale is 0, use the default */
+        if(u_locbund_init(&result->str.fBundle, locale) == 0) {
+            /* DO NOT FCLOSE HERE! */
+            uprv_free(result);
+            return 0;
+        }
+#endif
+
+    /* If the codepage is not "" use the ucnv_open default behavior */
+    if(codepage == NULL || *codepage != '\0') {
+        result->fConverter = ucnv_open(codepage, &status);
+    }
+    /* else result->fConverter is already memset'd to NULL. */
+
+    if(U_FAILURE(status)) {
+#if !UCONFIG_NO_FORMATTING
+        u_locbund_close(&result->str.fBundle);
+#endif
+        /* DO NOT fclose here!!!!!! */
+        uprv_free(result);
+        result = NULL;
+    }
+
+    return result;
+}
+
+U_CAPI UFILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fopen(const char    *filename,
+        const char    *perm,
+        const char    *locale,
+        const char    *codepage)
+{
+    UFILE     *result;
+    FILE     *systemFile = fopen(filename, perm);
+    if(systemFile == 0) {
+        return 0;
+    }
+
+    result = u_finit(systemFile, locale, codepage);
+
+    if (result) {
+        result->fOwnFile = TRUE;
+    }
+    else {
+        /* Something bad happened.
+           Maybe the converter couldn't be opened. */
+        fclose(systemFile);
+    }
+
+    return result;
+}
+
+U_CAPI UFILE* U_EXPORT2
+u_fstropen(UChar *stringBuf,
+           int32_t      capacity,
+           const char  *locale)
+{
+    UFILE *result;
+
+    if (capacity < 0) {
+        return NULL;
+    }
+
+    result = (UFILE*) uprv_malloc(sizeof(UFILE));
+    uprv_memset(result, 0, sizeof(UFILE));
+    result->str.fBuffer = stringBuf;
+    result->str.fPos    = stringBuf;
+    result->str.fLimit  = stringBuf+capacity;
+
+#if !UCONFIG_NO_FORMATTING
+    /* if locale is 0, use the default */
+    if(u_locbund_init(&result->str.fBundle, locale) == 0) {
+        /* DO NOT FCLOSE HERE! */
+        uprv_free(result);
+        return 0;
+    }
+#endif
+
+    return result;
+}
+
+U_CAPI UBool U_EXPORT2
+u_feof(UFILE  *f)
+{
+    UBool endOfBuffer;
+    if (f == NULL) {
+        return TRUE;
+    }
+    endOfBuffer = (UBool)(f->str.fPos >= f->str.fLimit);
+    if (f->fFile != NULL) {
+        return endOfBuffer && feof(f->fFile);
+    }
+    return endOfBuffer;
+}
+
+U_CAPI void U_EXPORT2
+u_fflush(UFILE *file)
+{
+    ufile_flush_translit(file);
+    if (file->fFile) {
+        fflush(file->fFile);
+    }
+    else if (file->str.fPos < file->str.fLimit) {
+        *(file->str.fPos++) = 0;
+    }
+    /* TODO: flush input */
+}
+
+U_CAPI void
+u_frewind(UFILE *file)
+{
+    u_fflush(file);
+    ucnv_reset(file->fConverter);
+    if (file->fFile) {
+        rewind(file->fFile);
+        file->str.fLimit = file->fUCBuffer;
+        file->str.fPos   = file->fUCBuffer;
+    }
+    else {
+        file->str.fPos = file->str.fBuffer;
+    }
+}
+
+U_CAPI void U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fclose(UFILE *file)
+{
+    u_fflush(file);
+    ufile_close_translit(file);
+
+    if(file->fOwnFile)
+        fclose(file->fFile);
+
+#if !UCONFIG_NO_FORMATTING
+    u_locbund_close(&file->str.fBundle);
+#endif
+
+    ucnv_close(file->fConverter);
+    uprv_free(file);
+}
+
+U_CAPI FILE* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetfile(    UFILE         *f)
+{
+    return f->fFile;
+}
+
+#if !UCONFIG_NO_FORMATTING
+
+U_CAPI const char*  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetlocale(    UFILE        *file)
+{
+    return file->str.fBundle.fLocale;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fsetlocale(UFILE      *file,
+             const char *locale)
+{
+    u_locbund_close(&file->str.fBundle);
+
+    return u_locbund_init(&file->str.fBundle, locale) == 0 ? -1 : 0;
+}
+
+#endif
+
+U_CAPI const char* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetcodepage(UFILE        *file)
+{
+    UErrorCode     status = U_ZERO_ERROR;
+    const char     *codepage = NULL;
+
+    if (file->fConverter) {
+        codepage = ucnv_getName(file->fConverter, &status);
+        if(U_FAILURE(status))
+            return 0;
+    }
+    return codepage;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fsetcodepage(    const char    *codepage,
+               UFILE        *file)
+{
+    UErrorCode status = U_ZERO_ERROR;
+    int32_t retVal = -1;
+
+    /* We use the normal default codepage for this system, and not the one for the locale. */
+    if ((file->str.fPos == file->str.fBuffer) && (file->str.fLimit == file->str.fBuffer)) {
+        ucnv_close(file->fConverter);
+        file->fConverter = ucnv_open(codepage, &status);
+        if(U_SUCCESS(status)) {
+            retVal = 0;
+        }
+    }
+    return retVal;
+}
+
+
+U_CAPI UConverter * U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetConverter(UFILE *file)
+{
+    return file->fConverter;
+}
+


Property changes on: trunk/source/io/ufile.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ufile.h
===================================================================
--- trunk/source/io/ufile.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ufile.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,125 +1,125 @@
-/*
-*******************************************************************************
-*
-*   Copyright (C) 1998-2005, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-*******************************************************************************
-*
-* File ufile.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/01/98    stephen        Creation.
-*   03/12/99    stephen     Modified for new C API.
-*******************************************************************************
-*/
-
-#ifndef UFILE_H
-#define UFILE_H
-
-#include "unicode/utypes.h"
-#include "unicode/ucnv.h"
-#include "unicode/utrans.h"
-#include "locbund.h"
-
-/* The buffer size for fromUnicode calls */
-#define UFILE_CHARBUFFER_SIZE 1024
-
-/* The buffer size for toUnicode calls */
-#define UFILE_UCHARBUFFER_SIZE 1024
-
-/* A UFILE */
-
-#if !UCONFIG_NO_TRANSLITERATION
-
-typedef struct {
-    UChar  *buffer;             /* Beginning of buffer */
-    int32_t capacity;           /* Capacity of buffer */
-    int32_t pos;                /* Beginning of untranslitted data */
-    int32_t length;             /* Length *from beginning of buffer* of untranslitted data */
-    UTransliterator *translit;
-} UFILETranslitBuffer;
-
-#endif
-
-typedef struct u_localized_string {
-    UChar       *fPos;          /* current pos in fUCBuffer */
-    const UChar *fLimit;        /* data limit in fUCBuffer */
-    UChar       *fBuffer;       /* Place to write the string */
-
-#if !UCONFIG_NO_FORMATTING
-    ULocaleBundle  fBundle; /* formatters */
-#endif
-} u_localized_string;
-
-struct UFILE {
-#if !UCONFIG_NO_TRANSLITERATION
-    UFILETranslitBuffer *fTranslit;
-#endif
-
-    FILE        *fFile;         /* the actual filesystem interface */
-
-    UConverter  *fConverter;    /* for codeset conversion */
-
-    u_localized_string str;     /* struct to handle strings for number formatting */
-
-    UChar       fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
-
-    UBool       fOwnFile;       /* TRUE if fFile should be closed */
-
-    int32_t     fFileno;        /* File number. Useful to determine if it's stdin. */
-};
-
-/**
- * Like u_file_write but takes a flush parameter
- */
-U_CAPI int32_t U_EXPORT2
-u_file_write_flush( const UChar     *chars, 
-        int32_t     count, 
-        UFILE       *f,
-        UBool       flushIO,
-        UBool       flushTranslit);
-
-/**
- * Fill a UFILE's buffer with converted codepage data.
- * @param f The UFILE containing the buffer to fill.
- */
-void
-ufile_fill_uchar_buffer(UFILE *f);
-
-/**
- * Get one code unit and detect whether the end of file has been reached.
- * @param f The UFILE containing the characters.
- * @param ch The read in character
- * @return TRUE if the character is valid, or FALSE when EOF has been detected
- */
-U_CFUNC UBool U_EXPORT2
-ufile_getch(UFILE *f, UChar *ch);
-
-/**
- * Get one character and detect whether the end of file has been reached.
- * @param f The UFILE containing the characters.
- * @param ch The read in character
- * @return TRUE if the character is valid, or FALSE when EOF has been detected
- */
-U_CFUNC UBool U_EXPORT2
-ufile_getch32(UFILE *f, UChar32 *ch);
-
-/**
- * Close out the transliterator and flush any data therein.
- * @param f flu
- */
-void 
-ufile_close_translit(UFILE *f);
-
-/**
- * Flush the buffer in the transliterator 
- * @param f UFile to flush
- */
-void 
-ufile_flush_translit(UFILE *f);
-
-
-#endif
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1998-2005, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*
+* File ufile.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/01/98    stephen        Creation.
+*   03/12/99    stephen     Modified for new C API.
+*******************************************************************************
+*/
+
+#ifndef UFILE_H
+#define UFILE_H
+
+#include "unicode/utypes.h"
+#include "unicode/ucnv.h"
+#include "unicode/utrans.h"
+#include "locbund.h"
+
+/* The buffer size for fromUnicode calls */
+#define UFILE_CHARBUFFER_SIZE 1024
+
+/* The buffer size for toUnicode calls */
+#define UFILE_UCHARBUFFER_SIZE 1024
+
+/* A UFILE */
+
+#if !UCONFIG_NO_TRANSLITERATION
+
+typedef struct {
+    UChar  *buffer;             /* Beginning of buffer */
+    int32_t capacity;           /* Capacity of buffer */
+    int32_t pos;                /* Beginning of untranslitted data */
+    int32_t length;             /* Length *from beginning of buffer* of untranslitted data */
+    UTransliterator *translit;
+} UFILETranslitBuffer;
+
+#endif
+
+typedef struct u_localized_string {
+    UChar       *fPos;          /* current pos in fUCBuffer */
+    const UChar *fLimit;        /* data limit in fUCBuffer */
+    UChar       *fBuffer;       /* Place to write the string */
+
+#if !UCONFIG_NO_FORMATTING
+    ULocaleBundle  fBundle; /* formatters */
+#endif
+} u_localized_string;
+
+struct UFILE {
+#if !UCONFIG_NO_TRANSLITERATION
+    UFILETranslitBuffer *fTranslit;
+#endif
+
+    FILE        *fFile;         /* the actual filesystem interface */
+
+    UConverter  *fConverter;    /* for codeset conversion */
+
+    u_localized_string str;     /* struct to handle strings for number formatting */
+
+    UChar       fUCBuffer[UFILE_UCHARBUFFER_SIZE];/* buffer used for toUnicode */
+
+    UBool       fOwnFile;       /* TRUE if fFile should be closed */
+
+    int32_t     fFileno;        /* File number. Useful to determine if it's stdin. */
+};
+
+/**
+ * Like u_file_write but takes a flush parameter
+ */
+U_CAPI int32_t U_EXPORT2
+u_file_write_flush( const UChar     *chars, 
+        int32_t     count, 
+        UFILE       *f,
+        UBool       flushIO,
+        UBool       flushTranslit);
+
+/**
+ * Fill a UFILE's buffer with converted codepage data.
+ * @param f The UFILE containing the buffer to fill.
+ */
+void
+ufile_fill_uchar_buffer(UFILE *f);
+
+/**
+ * Get one code unit and detect whether the end of file has been reached.
+ * @param f The UFILE containing the characters.
+ * @param ch The read in character
+ * @return TRUE if the character is valid, or FALSE when EOF has been detected
+ */
+U_CFUNC UBool U_EXPORT2
+ufile_getch(UFILE *f, UChar *ch);
+
+/**
+ * Get one character and detect whether the end of file has been reached.
+ * @param f The UFILE containing the characters.
+ * @param ch The read in character
+ * @return TRUE if the character is valid, or FALSE when EOF has been detected
+ */
+U_CFUNC UBool U_EXPORT2
+ufile_getch32(UFILE *f, UChar32 *ch);
+
+/**
+ * Close out the transliterator and flush any data therein.
+ * @param f flu
+ */
+void 
+ufile_close_translit(UFILE *f);
+
+/**
+ * Flush the buffer in the transliterator 
+ * @param f UFile to flush
+ */
+void 
+ufile_flush_translit(UFILE *f);
+
+
+#endif


Property changes on: trunk/source/io/ufile.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ufmt_cmn.c
===================================================================
--- trunk/source/io/ufmt_cmn.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ufmt_cmn.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,253 +1,253 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File ufmt_cmn.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/02/98    stephen     Creation.
-*   03/12/99    stephen     Modified for new C API.
-*   03/15/99    stephen     Added defaultCPToUnicode, unicodeToDefaultCP
-*   07/19/99    stephen     Fixed bug in defaultCPToUnicode
-******************************************************************************
-*/
-
-#include "cstring.h"
-#include "cmemory.h"
-#include "ufmt_cmn.h"
-#include "unicode/uchar.h"
-#include "unicode/ucnv.h"
-#include "ustr_cnv.h"
-
-#define DIGIT_0     0x0030
-#define DIGIT_9     0x0039
-#define LOWERCASE_A 0x0061
-#define UPPERCASE_A 0x0041
-#define LOWERCASE_Z 0x007A
-#define UPPERCASE_Z 0x005A
-
-int
-ufmt_digitvalue(UChar c)
-{
-    if( ((c>=DIGIT_0)&&(c<=DIGIT_9)) ||
-        ((c>=LOWERCASE_A)&&(c<=LOWERCASE_Z)) ||
-        ((c>=UPPERCASE_A)&&(c<=UPPERCASE_Z))  )
-    {
-      return c - DIGIT_0 - (c >= 0x0041 ? (c >= 0x0061 ? 39 : 7) : 0);
-    }
-    else
-    {
-      return -1;
-    }
-}
-
-UBool
-ufmt_isdigit(UChar     c,
-             int32_t     radix)
-{
-    int digitVal = ufmt_digitvalue(c);
-
-    return (UBool)(digitVal < radix && digitVal >= 0);
-}
-
-#define TO_UC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0037 + a)
-#define TO_LC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0057 + a)
-
-void 
-ufmt_64tou(UChar     *buffer, 
-          int32_t   *len,
-          uint64_t  value, 
-          uint8_t  radix,
-          UBool     uselower,
-          int32_t   minDigits)
-{
-    int32_t  length = 0;
-    uint32_t digit;
-    UChar    *left, *right, temp;
-    
-    do {
-        digit = (uint32_t)(value % radix);
-        value = value / radix;
-        buffer[length++] = (UChar)(uselower ? TO_LC_DIGIT(digit) 
-            : TO_UC_DIGIT(digit));
-    } while(value);
-
-    /* pad with zeroes to make it minDigits long */
-    if(minDigits != -1 && length < minDigits) {
-        while(length < minDigits && length < *len)
-            buffer[length++] = DIGIT_0;  /*zero padding */
-    }
-
-    /* reverse the buffer */
-    left     = buffer;
-    right = buffer + length;
-    while(left < --right) {
-        temp     = *left;
-        *left++     = *right;
-        *right     = temp;
-    }
-    
-    *len = length;
-}
-
-void 
-ufmt_ptou(UChar    *buffer, 
-          int32_t   *len,
-          void      *value, 
-          UBool     uselower)
-{
-    int32_t i;
-    int32_t length = 0;
-    uint8_t *ptrIdx = (uint8_t *)&value;
-
-#if U_IS_BIG_ENDIAN
-    for (i = 0; i < (int32_t)sizeof(void *); i++)
-#else
-    for (i = (int32_t)sizeof(void *)-1; i >= 0 ; i--)
-#endif
-    {
-        uint8_t byteVal = ptrIdx[i];
-        uint16_t firstNibble = (uint16_t)(byteVal>>4);
-        uint16_t secondNibble = (uint16_t)(byteVal&0xF);
-        if (uselower) {
-            buffer[length++]=TO_LC_DIGIT(firstNibble);
-            buffer[length++]=TO_LC_DIGIT(secondNibble);
-        }
-        else {
-            buffer[length++]=TO_UC_DIGIT(firstNibble);
-            buffer[length++]=TO_UC_DIGIT(secondNibble);
-        }
-    }
-
-    *len = length;
-}
-
-int64_t
-ufmt_uto64(const UChar     *buffer, 
-          int32_t     *len,
-          int8_t     radix)
-{
-    const UChar     *limit;
-    int32_t         count;
-    int64_t        result;
-    
-    
-    /* intialize parameters */
-    limit     = buffer + *len;
-    count     = 0;
-    result    = 0;
-    
-    /* iterate through buffer */
-    while(ufmt_isdigit(*buffer, radix) && buffer < limit) {
-        
-        /* read the next digit */
-        result *= radix;
-        result += ufmt_digitvalue(*buffer++);
-        
-        /* increment our count */
-        ++count;
-    }
-    
-    *len = count;
-    return result;
-}
-
-#define NIBBLE_PER_BYTE 2
-void *
-ufmt_utop(const UChar     *buffer,
-          int32_t     *len)
-{
-    int32_t count, resultIdx, incVal, offset;
-    /* This union allows the pointer to be written as an array. */
-    union {
-        void *ptr;
-        uint8_t bytes[sizeof(void*)];
-    } result;
-    
-    /* intialize variables */
-    count      = 0;
-    offset     = 0;
-    result.ptr = NULL;
-
-    /* Skip the leading zeros */
-    while(buffer[count] == DIGIT_0 || u_isspace(buffer[count])) {
-        count++;
-        offset++;
-    }
-
-    /* iterate through buffer, stop when you hit the end */
-    while(ufmt_isdigit(buffer[count], 16) && count < *len) {
-        /* increment the count consumed */
-        ++count;
-    }
-
-    /* detect overflow */
-    if (count - offset > (int32_t)(sizeof(void*)*NIBBLE_PER_BYTE)) {
-        offset = count - (int32_t)(sizeof(void*)*NIBBLE_PER_BYTE);
-    }
-    
-    /* Initialize the direction of the input */
-#if U_IS_BIG_ENDIAN
-    incVal = -1;
-    resultIdx = (int32_t)(sizeof(void*) - 1);
-#else
-    incVal = 1;
-    resultIdx = 0;
-#endif
-    /* Write how much was consumed. */
-    *len = count;
-    while(--count >= offset) {
-        /* Get the first nibble of the byte */
-        uint8_t byte = (uint8_t)ufmt_digitvalue(buffer[count]);
-
-        if (count > offset) {
-            /* Get the second nibble of the byte when available */
-            byte = (uint8_t)(byte + (ufmt_digitvalue(buffer[--count]) << 4));
-        }
-        /* Write the byte into the array */
-        result.bytes[resultIdx] = byte;
-        resultIdx += incVal;
-    }
-
-    return result.ptr;
-}
-
-UChar*
-ufmt_defaultCPToUnicode(const char *s, int32_t sSize,
-                        UChar *target, int32_t tSize)
-{
-    UChar *alias;
-    UErrorCode status = U_ZERO_ERROR;
-    UConverter *defConverter = u_getDefaultConverter(&status);
-    
-    if(U_FAILURE(status) || defConverter == 0)
-        return 0;
-
-    if(sSize <= 0) {
-        sSize = uprv_strlen(s) + 1;
-    }
-    
-    /* perform the conversion in one swoop */
-    if(target != 0) {
-        
-        alias = target;
-        ucnv_toUnicode(defConverter, &alias, alias + tSize, &s, s + sSize - 1, 
-            NULL, TRUE, &status);
-        
-        
-        /* add the null terminator */
-        *alias = 0x0000;
-    }
-    
-    u_releaseDefaultConverter(defConverter);
-    
-    return target;
-}
-
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ufmt_cmn.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/02/98    stephen     Creation.
+*   03/12/99    stephen     Modified for new C API.
+*   03/15/99    stephen     Added defaultCPToUnicode, unicodeToDefaultCP
+*   07/19/99    stephen     Fixed bug in defaultCPToUnicode
+******************************************************************************
+*/
+
+#include "cstring.h"
+#include "cmemory.h"
+#include "ufmt_cmn.h"
+#include "unicode/uchar.h"
+#include "unicode/ucnv.h"
+#include "ustr_cnv.h"
+
+#define DIGIT_0     0x0030
+#define DIGIT_9     0x0039
+#define LOWERCASE_A 0x0061
+#define UPPERCASE_A 0x0041
+#define LOWERCASE_Z 0x007A
+#define UPPERCASE_Z 0x005A
+
+int
+ufmt_digitvalue(UChar c)
+{
+    if( ((c>=DIGIT_0)&&(c<=DIGIT_9)) ||
+        ((c>=LOWERCASE_A)&&(c<=LOWERCASE_Z)) ||
+        ((c>=UPPERCASE_A)&&(c<=UPPERCASE_Z))  )
+    {
+      return c - DIGIT_0 - (c >= 0x0041 ? (c >= 0x0061 ? 39 : 7) : 0);
+    }
+    else
+    {
+      return -1;
+    }
+}
+
+UBool
+ufmt_isdigit(UChar     c,
+             int32_t     radix)
+{
+    int digitVal = ufmt_digitvalue(c);
+
+    return (UBool)(digitVal < radix && digitVal >= 0);
+}
+
+#define TO_UC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0037 + a)
+#define TO_LC_DIGIT(a) a <= 9 ? (DIGIT_0 + a) : (0x0057 + a)
+
+void 
+ufmt_64tou(UChar     *buffer, 
+          int32_t   *len,
+          uint64_t  value, 
+          uint8_t  radix,
+          UBool     uselower,
+          int32_t   minDigits)
+{
+    int32_t  length = 0;
+    uint32_t digit;
+    UChar    *left, *right, temp;
+    
+    do {
+        digit = (uint32_t)(value % radix);
+        value = value / radix;
+        buffer[length++] = (UChar)(uselower ? TO_LC_DIGIT(digit) 
+            : TO_UC_DIGIT(digit));
+    } while(value);
+
+    /* pad with zeroes to make it minDigits long */
+    if(minDigits != -1 && length < minDigits) {
+        while(length < minDigits && length < *len)
+            buffer[length++] = DIGIT_0;  /*zero padding */
+    }
+
+    /* reverse the buffer */
+    left     = buffer;
+    right = buffer + length;
+    while(left < --right) {
+        temp     = *left;
+        *left++     = *right;
+        *right     = temp;
+    }
+    
+    *len = length;
+}
+
+void 
+ufmt_ptou(UChar    *buffer, 
+          int32_t   *len,
+          void      *value, 
+          UBool     uselower)
+{
+    int32_t i;
+    int32_t length = 0;
+    uint8_t *ptrIdx = (uint8_t *)&value;
+
+#if U_IS_BIG_ENDIAN
+    for (i = 0; i < (int32_t)sizeof(void *); i++)
+#else
+    for (i = (int32_t)sizeof(void *)-1; i >= 0 ; i--)
+#endif
+    {
+        uint8_t byteVal = ptrIdx[i];
+        uint16_t firstNibble = (uint16_t)(byteVal>>4);
+        uint16_t secondNibble = (uint16_t)(byteVal&0xF);
+        if (uselower) {
+            buffer[length++]=TO_LC_DIGIT(firstNibble);
+            buffer[length++]=TO_LC_DIGIT(secondNibble);
+        }
+        else {
+            buffer[length++]=TO_UC_DIGIT(firstNibble);
+            buffer[length++]=TO_UC_DIGIT(secondNibble);
+        }
+    }
+
+    *len = length;
+}
+
+int64_t
+ufmt_uto64(const UChar     *buffer, 
+          int32_t     *len,
+          int8_t     radix)
+{
+    const UChar     *limit;
+    int32_t         count;
+    int64_t        result;
+    
+    
+    /* intialize parameters */
+    limit     = buffer + *len;
+    count     = 0;
+    result    = 0;
+    
+    /* iterate through buffer */
+    while(ufmt_isdigit(*buffer, radix) && buffer < limit) {
+        
+        /* read the next digit */
+        result *= radix;
+        result += ufmt_digitvalue(*buffer++);
+        
+        /* increment our count */
+        ++count;
+    }
+    
+    *len = count;
+    return result;
+}
+
+#define NIBBLE_PER_BYTE 2
+void *
+ufmt_utop(const UChar     *buffer,
+          int32_t     *len)
+{
+    int32_t count, resultIdx, incVal, offset;
+    /* This union allows the pointer to be written as an array. */
+    union {
+        void *ptr;
+        uint8_t bytes[sizeof(void*)];
+    } result;
+    
+    /* intialize variables */
+    count      = 0;
+    offset     = 0;
+    result.ptr = NULL;
+
+    /* Skip the leading zeros */
+    while(buffer[count] == DIGIT_0 || u_isspace(buffer[count])) {
+        count++;
+        offset++;
+    }
+
+    /* iterate through buffer, stop when you hit the end */
+    while(ufmt_isdigit(buffer[count], 16) && count < *len) {
+        /* increment the count consumed */
+        ++count;
+    }
+
+    /* detect overflow */
+    if (count - offset > (int32_t)(sizeof(void*)*NIBBLE_PER_BYTE)) {
+        offset = count - (int32_t)(sizeof(void*)*NIBBLE_PER_BYTE);
+    }
+    
+    /* Initialize the direction of the input */
+#if U_IS_BIG_ENDIAN
+    incVal = -1;
+    resultIdx = (int32_t)(sizeof(void*) - 1);
+#else
+    incVal = 1;
+    resultIdx = 0;
+#endif
+    /* Write how much was consumed. */
+    *len = count;
+    while(--count >= offset) {
+        /* Get the first nibble of the byte */
+        uint8_t byte = (uint8_t)ufmt_digitvalue(buffer[count]);
+
+        if (count > offset) {
+            /* Get the second nibble of the byte when available */
+            byte = (uint8_t)(byte + (ufmt_digitvalue(buffer[--count]) << 4));
+        }
+        /* Write the byte into the array */
+        result.bytes[resultIdx] = byte;
+        resultIdx += incVal;
+    }
+
+    return result.ptr;
+}
+
+UChar*
+ufmt_defaultCPToUnicode(const char *s, int32_t sSize,
+                        UChar *target, int32_t tSize)
+{
+    UChar *alias;
+    UErrorCode status = U_ZERO_ERROR;
+    UConverter *defConverter = u_getDefaultConverter(&status);
+    
+    if(U_FAILURE(status) || defConverter == 0)
+        return 0;
+
+    if(sSize <= 0) {
+        sSize = uprv_strlen(s) + 1;
+    }
+    
+    /* perform the conversion in one swoop */
+    if(target != 0) {
+        
+        alias = target;
+        ucnv_toUnicode(defConverter, &alias, alias + tSize, &s, s + sSize - 1, 
+            NULL, TRUE, &status);
+        
+        
+        /* add the null terminator */
+        *alias = 0x0000;
+    }
+    
+    u_releaseDefaultConverter(defConverter);
+    
+    return target;
+}
+
+


Property changes on: trunk/source/io/ufmt_cmn.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ufmt_cmn.h
===================================================================
--- trunk/source/io/ufmt_cmn.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ufmt_cmn.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,159 +1,159 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File ufmt_cmn.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/02/98    stephen        Creation.
-*   03/12/99    stephen     Modified for new C API.
-*   03/15/99    stephen     Added defaultCPToUnicode, unicodeToDefaultCP
-******************************************************************************
-*/
-
-#ifndef UFMT_CMN_H
-#define UFMT_CMN_H
-
-#include "unicode/utypes.h"
-
-#define UFMT_DEFAULT_BUFFER_SIZE 128
-#define MAX_UCHAR_BUFFER_SIZE(buffer) (sizeof(buffer)/(UTF_MAX_CHAR_LENGTH*sizeof(UChar)))
-#define MAX_UCHAR_BUFFER_NEEDED(strLen) ((strLen+1)*UTF_MAX_CHAR_LENGTH*sizeof(UChar))
-
-/** 
- * Enum representing the possible argument types for uprintf/uscanf
- */
-typedef enum ufmt_type_info {
-    ufmt_empty = 0,
-    ufmt_simple_percent, /* %% do nothing */
-    ufmt_count,      /* special flag for count */
-    ufmt_int,        /* int */
-    ufmt_char,       /* int, cast to char */
-    ufmt_string,     /* char* */
-    ufmt_pointer,    /* void* */
-    ufmt_float,      /* float */
-    ufmt_double,     /* double */
-    ufmt_uchar,      /* int, cast to UChar */
-    ufmt_ustring     /* UChar* */
-    /*ufmt_wchar,*/      /* wchar_t */
-    /*ufmt_wstring,*/    /* wchar_t* */
-    /*ufmt_date,*/       /* Date */
-    /*ufmt_last*/
-} ufmt_type_info;
-
-/**
- * Union representing a uprintf/uscanf argument
- */
-typedef union ufmt_args {
-    int64_t int64Value;    /* int, UChar */
-    float   floatValue;    /* float */
-    double  doubleValue;   /* double */
-    void    *ptrValue;     /* any pointer - void*, char*, wchar_t*, UChar* */
-    /*wchar_t wcharValue;*/    /* wchar_t */    /* TODO: Should wchar_t be used? */
-    /*UDate dateValue;*/     /* Date */
-} ufmt_args;
-
-/**
- * Macro for determining the minimum of two numbers.
- * @param a An integer
- * @param b An integer
- * @return <TT>a</TT> if </TT>a < b</TT>, <TT>b</TT> otherwise
- */
-#define ufmt_min(a,b) ((a) < (b) ? (a) : (b))
-
-/**
- * Convert a UChar in hex radix to an integer value.
- * @param c The UChar to convert.
- * @return The integer value of <TT>c</TT>.
- */
-int
-ufmt_digitvalue(UChar c);
-
-/**
- * Determine if a UChar is a digit for a specified radix.
- * @param c The UChar to check.
- * @param radix The desired radix.
- * @return TRUE if <TT>c</TT> is a digit in <TT>radix</TT>, FALSE otherwise.
- */
-UBool
-ufmt_isdigit(UChar     c,
-         int32_t     radix);
-
-/**
- * Convert an int64_t to a UChar* in a specified radix
- * @param buffer The target buffer
- * @param len On input, the size of <TT>buffer</TT>.  On output,
- * the number of UChars written to <TT>buffer</TT>.
- * @param value The value to be converted
- * @param radix The desired radix
- * @param uselower TRUE means lower case will be used, FALSE means upper case
- * @param minDigits The minimum number of digits for for the formatted number,
- * which will be padded with zeroes. -1 means do not pad.
- */
-void 
-ufmt_64tou(UChar     *buffer, 
-      int32_t     *len,
-      uint64_t     value, 
-      uint8_t     radix,
-      UBool    uselower,
-      int32_t    minDigits);
-
-/**
- * It's like ufmt_64tou, but with a pointer.
- * This functions avoids size constraints of 64-bit types.
- * Pointers can be at 32-128 bits in size.
- */
-void 
-ufmt_ptou(UChar    *buffer, 
-          int32_t   *len,
-          void      *value, 
-          UBool     uselower);
-
-/**
- * Convert a UChar* in a specified radix to an int64_t.
- * @param buffer The target buffer
- * @param len On input, the size of <TT>buffer</TT>.  On output,
- * the number of UChars read from <TT>buffer</TT>.
- * @param radix The desired radix
- * @return The numeric value.
- */
-int64_t
-ufmt_uto64(const UChar     *buffer, 
-      int32_t     *len,
-      int8_t     radix);
-
-/**
- * Convert a UChar* in a specified radix to a pointer,
- * @param buffer The target buffer
- * @param len On input, the size of <TT>buffer</TT>.  On output,
- * the number of UChars read from <TT>buffer</TT>.
- * @param radix The desired radix
- * @return The pointer value.
- */
-void *
-ufmt_utop(const UChar     *buffer,
-      int32_t     *len);
-
-/**
- * Convert a string from the default codepage to Unicode.
- * @param s The string to convert, in the default codepage.
- * @param sSize The size of s to convert.
- * @param target The buffer to convert to.
- * @param tSize The size of target
- * @return A pointer to a newly allocated converted version of s, or 0 
- * on error.
- */
-UChar*
-ufmt_defaultCPToUnicode(const char *s, int32_t sSize,
-                        UChar *target, int32_t tSize);
-
-
-
-#endif
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ufmt_cmn.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/02/98    stephen        Creation.
+*   03/12/99    stephen     Modified for new C API.
+*   03/15/99    stephen     Added defaultCPToUnicode, unicodeToDefaultCP
+******************************************************************************
+*/
+
+#ifndef UFMT_CMN_H
+#define UFMT_CMN_H
+
+#include "unicode/utypes.h"
+
+#define UFMT_DEFAULT_BUFFER_SIZE 128
+#define MAX_UCHAR_BUFFER_SIZE(buffer) (sizeof(buffer)/(UTF_MAX_CHAR_LENGTH*sizeof(UChar)))
+#define MAX_UCHAR_BUFFER_NEEDED(strLen) ((strLen+1)*UTF_MAX_CHAR_LENGTH*sizeof(UChar))
+
+/** 
+ * Enum representing the possible argument types for uprintf/uscanf
+ */
+typedef enum ufmt_type_info {
+    ufmt_empty = 0,
+    ufmt_simple_percent, /* %% do nothing */
+    ufmt_count,      /* special flag for count */
+    ufmt_int,        /* int */
+    ufmt_char,       /* int, cast to char */
+    ufmt_string,     /* char* */
+    ufmt_pointer,    /* void* */
+    ufmt_float,      /* float */
+    ufmt_double,     /* double */
+    ufmt_uchar,      /* int, cast to UChar */
+    ufmt_ustring     /* UChar* */
+    /*ufmt_wchar,*/      /* wchar_t */
+    /*ufmt_wstring,*/    /* wchar_t* */
+    /*ufmt_date,*/       /* Date */
+    /*ufmt_last*/
+} ufmt_type_info;
+
+/**
+ * Union representing a uprintf/uscanf argument
+ */
+typedef union ufmt_args {
+    int64_t int64Value;    /* int, UChar */
+    float   floatValue;    /* float */
+    double  doubleValue;   /* double */
+    void    *ptrValue;     /* any pointer - void*, char*, wchar_t*, UChar* */
+    /*wchar_t wcharValue;*/    /* wchar_t */    /* TODO: Should wchar_t be used? */
+    /*UDate dateValue;*/     /* Date */
+} ufmt_args;
+
+/**
+ * Macro for determining the minimum of two numbers.
+ * @param a An integer
+ * @param b An integer
+ * @return <TT>a</TT> if </TT>a < b</TT>, <TT>b</TT> otherwise
+ */
+#define ufmt_min(a,b) ((a) < (b) ? (a) : (b))
+
+/**
+ * Convert a UChar in hex radix to an integer value.
+ * @param c The UChar to convert.
+ * @return The integer value of <TT>c</TT>.
+ */
+int
+ufmt_digitvalue(UChar c);
+
+/**
+ * Determine if a UChar is a digit for a specified radix.
+ * @param c The UChar to check.
+ * @param radix The desired radix.
+ * @return TRUE if <TT>c</TT> is a digit in <TT>radix</TT>, FALSE otherwise.
+ */
+UBool
+ufmt_isdigit(UChar     c,
+         int32_t     radix);
+
+/**
+ * Convert an int64_t to a UChar* in a specified radix
+ * @param buffer The target buffer
+ * @param len On input, the size of <TT>buffer</TT>.  On output,
+ * the number of UChars written to <TT>buffer</TT>.
+ * @param value The value to be converted
+ * @param radix The desired radix
+ * @param uselower TRUE means lower case will be used, FALSE means upper case
+ * @param minDigits The minimum number of digits for for the formatted number,
+ * which will be padded with zeroes. -1 means do not pad.
+ */
+void 
+ufmt_64tou(UChar     *buffer, 
+      int32_t     *len,
+      uint64_t     value, 
+      uint8_t     radix,
+      UBool    uselower,
+      int32_t    minDigits);
+
+/**
+ * It's like ufmt_64tou, but with a pointer.
+ * This functions avoids size constraints of 64-bit types.
+ * Pointers can be at 32-128 bits in size.
+ */
+void 
+ufmt_ptou(UChar    *buffer, 
+          int32_t   *len,
+          void      *value, 
+          UBool     uselower);
+
+/**
+ * Convert a UChar* in a specified radix to an int64_t.
+ * @param buffer The target buffer
+ * @param len On input, the size of <TT>buffer</TT>.  On output,
+ * the number of UChars read from <TT>buffer</TT>.
+ * @param radix The desired radix
+ * @return The numeric value.
+ */
+int64_t
+ufmt_uto64(const UChar     *buffer, 
+      int32_t     *len,
+      int8_t     radix);
+
+/**
+ * Convert a UChar* in a specified radix to a pointer,
+ * @param buffer The target buffer
+ * @param len On input, the size of <TT>buffer</TT>.  On output,
+ * the number of UChars read from <TT>buffer</TT>.
+ * @param radix The desired radix
+ * @return The pointer value.
+ */
+void *
+ufmt_utop(const UChar     *buffer,
+      int32_t     *len);
+
+/**
+ * Convert a string from the default codepage to Unicode.
+ * @param s The string to convert, in the default codepage.
+ * @param sSize The size of s to convert.
+ * @param target The buffer to convert to.
+ * @param tSize The size of target
+ * @return A pointer to a newly allocated converted version of s, or 0 
+ * on error.
+ */
+UChar*
+ufmt_defaultCPToUnicode(const char *s, int32_t sSize,
+                        UChar *target, int32_t tSize);
+
+
+
+#endif
+


Property changes on: trunk/source/io/ufmt_cmn.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/unicode/ustdio.h
===================================================================
--- trunk/source/io/unicode/ustdio.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/unicode/ustdio.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,891 +1,891 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File ustdio.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   10/16/98    stephen     Creation.
-*   11/06/98    stephen     Modified per code review.
-*   03/12/99    stephen     Modified for new C API.
-*   07/19/99    stephen     Minor doc update.
-*   02/01/01    george      Added sprintf & sscanf with all of its variants
-******************************************************************************
-*/
-
-#ifndef USTDIO_H
-#define USTDIO_H
-
-#include <stdio.h>
-#include <stdarg.h>
-
-#include "unicode/utypes.h"
-#include "unicode/ucnv.h"
-#include "unicode/utrans.h"
-
-/*
-    TODO
- The following is a small list as to what is currently wrong/suggestions for
- ustdio.
-
- * Make sure that * in the scanf format specification works for all formats.
- * Each UFILE takes up at least 2KB.
-    Look into adding setvbuf() for configurable buffers.
- * This library does buffering. The OS should do this for us already. Check on
-    this, and remove it from this library, if this is the case. Double buffering
-    wastes a lot of time and space.
- * Test stdin and stdout with the u_f* functions
- * Testing should be done for reading and writing multi-byte encodings,
-    and make sure that a character that is contained across buffer boundries
-    works even for incomplete characters.
- * Make sure that the last character is flushed when the file/string is closed.
- * snprintf should follow the C99 standard for the return value, which is
-    return the number of characters (excluding the trailing '\0')
-    which would have been written to the destination string regardless
-    of available space. This is like pre-flighting.
- * Everything that uses %s should do what operator>> does for UnicodeString.
-    It should convert one byte at a time, and once a character is
-    converted then check to see if it's whitespace or in the scanset.
-    If it's whitespace or in the scanset, put all the bytes back (do nothing
-    for sprintf/sscanf).
- * If bad string data is encountered, make sure that the function fails
-    without memory leaks and the unconvertable characters are valid
-    substitution or are escaped characters.
- * u_fungetc() can't unget a character when it's at the beginning of the
-    internal conversion buffer. For example, read the buffer size # of
-    characters, and then ungetc to get the previous character that was
-    at the end of the last buffer.
- * u_fflush() and u_fclose should return an int32_t like C99 functions.
-    0 is returned if the operation was successful and EOF otherwise.
- * u_fsettransliterator does not support U_READ side of transliteration.
- * The format specifier should limit the size of a format or honor it in
-    order to prevent buffer overruns.  (e.g. %256.256d).
- * u_fread and u_fwrite don't exist. They're needed for reading and writing
-    data structures without any conversion.
- * u_file_read and u_file_write are used for writing strings. u_fgets and
-    u_fputs or u_fread and u_fwrite should be used to do this.
- * The width parameter for all scanf formats, including scanset, needs
-    better testing. This prevents buffer overflows.
- * Figure out what is suppose to happen when a codepage is changed midstream.
-    Maybe a flush or a rewind are good enough.
- * Make sure that a UFile opened with "rw" can be used after using
-    u_fflush with a u_frewind.
- * scanf(%i) should detect what type of number to use.
- * Add more testing of the alternate format, %#
- * Look at newline handling of fputs/puts
- * Think more about codeunit/codepoint error handling/support in %S,%s,%C,%c,%[]
- * Complete the file documentation with proper doxygen formatting.
-    See http://oss.software.ibm.com/pipermail/icu/2003-July/005647.html
-*/
-
-/**
- * \file
- * \brief C API: Unicode stdio-like API
- *
- * <h2>Unicode stdio-like C API</h2>
- *
- * <p>This API provides an stdio-like API wrapper around ICU's other
- * formatting and parsing APIs. It is meant to ease the transition of adding
- * Unicode support to a preexisting applications using stdio. The following
- * is a small list of noticable differences between stdio and ICU I/O's
- * ustdio implementation.</p>
- *
- * <ul>
- * <li>Locale specific formatting and parsing is only done with file IO.</li>
- * <li>u_fstropen can be used to simulate file IO with strings.
- * This is similar to the iostream API, and it allows locale specific
- * formatting and parsing to be used.</li>
- * <li>This API provides uniform formatting and parsing behavior between
- * platforms (unlike the standard stdio implementations found on various
- * platforms).</li>
- * <li>This API is better suited for text data handling than binary data
- * handling when compared to the typical stdio implementation.</li>
- * <li>You can specify a Transliterator while using the file IO.</li>
- * <li>You can specify a file's codepage separately from the default
- * system codepage.</li>
- * </ul>
- *
- * <h2>Formatting and Parsing Specification</h2>
- *
- * General printf format:<br>
- * %[format modifier][width][.precision][type modifier][format]
- * 
- * General scanf format:<br>
- * %[*][format modifier][width][type modifier][format]
- * 
-<table cellspacing="3">
-<tr><td>format</td><td>default<br>printf<br>type</td><td>default<br>scanf<br>type</td><td>description</td></tr>
-<tr><td>%E</td><td>double</td><td>float</td><td>Scientific with an uppercase exponent</td></tr>
-<tr><td>%e</td><td>double</td><td>float</td><td>Scientific with a lowercase exponent</td></tr>
-<tr><td>%G</td><td>double</td><td>float</td><td>Use %E or %f for best format</td></tr>
-<tr><td>%g</td><td>double</td><td>float</td><td>Use %e or %f for best format</td></tr>
-<tr><td>%f</td><td>double</td><td>float</td><td>Simple floating point without the exponent</td></tr>
-<tr><td>%X</td><td>int32_t</td><td>int32_t</td><td>ustdio special uppercase hex radix formatting</td></tr>
-<tr><td>%x</td><td>int32_t</td><td>int32_t</td><td>ustdio special lowercase hex radix formatting</td></tr>
-<tr><td>%d</td><td>int32_t</td><td>int32_t</td><td>Decimal format</td></tr>
-<tr><td>%i</td><td>int32_t</td><td>int32_t</td><td>Same as %d</td></tr>
-<tr><td>%n</td><td>int32_t</td><td>int32_t</td><td>count (write the number of UTF-16 codeunits read/written)</td></tr>
-<tr><td>%o</td><td>int32_t</td><td>int32_t</td><td>ustdio special octal radix formatting</td></tr>
-<tr><td>%u</td><td>uint32_t</td><td>uint32_t</td><td>Decimal format</td></tr>
-<tr><td>%p</td><td>void *</td><td>void *</td><td>Prints the pointer value</td></tr>
-<tr><td>%s</td><td>char *</td><td>char *</td><td>Use default converter or specified converter from fopen</td></tr>
-<tr><td>%c</td><td>char</td><td>char</td><td>Use default converter or specified converter from fopen<br>
-When width is specified for scanf, this acts like a non-NULL-terminated char * string.<br>
-By default, only one char is written.</td></tr>
-<tr><td>%S</td><td>UChar *</td><td>UChar *</td><td>Null terminated UTF-16 string</td></tr>
-<tr><td>%C</td><td>UChar</td><td>UChar</td><td>16-bit Unicode code unit<br>
-When width is specified for scanf, this acts like a non-NULL-terminated UChar * string<br>
-By default, only one codepoint is written.</td></tr>
-<tr><td>%[]</td><td>&nbsp;</td><td>UChar *</td><td>Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet</td></tr>
-<tr><td>%%</td><td>&nbsp;</td><td>&nbsp;</td><td>Show a percent sign</td></tr>
-</table>
-
-Format modifiers
-<table>
-<tr><td>modifier</td><td>formats</td><td>type</td><td>comments</td></tr>
-<tr><td>%h</td><td>%d, %i, %o, %x</td><td>int16_t</td><td>short format</td></tr>
-<tr><td>%h</td><td>%u</td><td>uint16_t</td><td>short format</td></tr>
-<tr><td>%h</td><td>c</td><td>char</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
-<tr><td>%h</td><td>s</td><td>char *</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
-<tr><td>%h</td><td>C</td><td>char</td><td><b>(Unimplemented)</b> 8-bit Unicode code unit</td></tr>
-<tr><td>%h</td><td>S</td><td>char *</td><td><b>(Unimplemented)</b> Null terminated UTF-8 string</td></tr>
-<tr><td>%l</td><td>%d, %i, %o, %x</td><td>int32_t</td><td>long format (no effect)</td></tr>
-<tr><td>%l</td><td>%u</td><td>uint32_t</td><td>long format (no effect)</td></tr>
-<tr><td>%l</td><td>c</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
-<tr><td>%l</td><td>s</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
-<tr><td>%l</td><td>C</td><td>UChar32</td><td><b>(Unimplemented)</b> 32-bit Unicode code unit</td></tr>
-<tr><td>%l</td><td>S</td><td>UChar32 *</td><td><b>(Unimplemented)</b> Null terminated UTF-32 string</td></tr>
-<tr><td>%ll</td><td>%d, %i, %o, %x</td><td>int64_t</td><td>long long format</td></tr>
-<tr><td>%ll</td><td>%u</td><td>uint64_t</td><td><b>(Unimplemented)</b> long long format</td></tr>
-<tr><td>%-</td><td><i>all</i></td><td>N/A</td><td>Left justify</td></tr>
-<tr><td>%+</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Always show the plus or minus sign. Needs data for plus sign.</td></tr>
-<tr><td>% </td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Instead of a "+" output a blank character for positive numbers.</td></tr>
-<tr><td>%#</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Precede octal value with 0, hex with 0x and show the 
-                decimal point for floats.</td></tr>
-<tr><td>%<i>n</i></td><td><i>all</i></td><td>N/A</td><td>Width of input/output. num is an actual number from 0 to 
-                some large number.</td></tr>
-<tr><td>%.<i>n</i></td><td>%e, %f, %g, %E, %F, %G</td><td>N/A</td><td>Significant digits precision. num is an actual number from
-                0 to some large number.<br>If * is used in printf, then the precision is passed in as an argument before the number to be formatted.</td></tr>
-</table>
-
-printf modifier
-%*  int32_t     Next argument after this one specifies the width
-
-scanf modifier
-%*  N/A         This field is scanned, but not stored
-
- */
-
-
-/**
- * When an end of file is encountered, this value can be returned.
- * @see u_fgetc
- * @stable 3.0
- */
-#define U_EOF 0xFFFF
-
-/** Forward declaration of a Unicode-aware file @stable 3.0 */
-typedef struct UFILE UFILE;
-
-#ifndef U_HIDE_DRAFT_API
-/**
- * Enum for which direction of stream a transliterator applies to.
- * @see u_fsettransliterator
- * @draft 3.0
- */
-typedef enum { 
-   U_READ = 1,
-   U_WRITE = 2, 
-   U_READWRITE =3  /* == (U_READ | U_WRITE) */ 
-} UFileDirection;
-
-#endif /* U_HIDE_DRAFT_API */
-
-/**
- * Open a UFILE.
- * A UFILE is a wrapper around a FILE* that is locale and codepage aware.
- * That is, data written to a UFILE will be formatted using the conventions
- * specified by that UFILE's Locale; this data will be in the character set
- * specified by that UFILE's codepage.
- * @param filename The name of the file to open.
- * @param perm The read/write permission for the UFILE; one of "r", "w", "rw"
- * @param locale The locale whose conventions will be used to format 
- * and parse output. If this parameter is NULL, the default locale will 
- * be used.
- * @param codepage The codepage in which data will be written to and
- * read from the file. If this paramter is NULL the system default codepage
- * will be used.
- * @return A new UFILE, or NULL if an error occurred.
- * @draft 3.0
- */
-U_DRAFT UFILE* U_EXPORT2
-u_fopen(const char    *filename,
-    const char    *perm,
-    const char    *locale,
-    const char    *codepage);
-
-/**
- * Open a UFILE on top of an existing FILE* stream.
- * @param f The FILE* to which this UFILE will attach.
- * @param locale The locale whose conventions will be used to format 
- * and parse output. If this parameter is NULL, the default locale will 
- * be used.
- * @param codepage The codepage in which data will be written to and
- * read from the file. If this paramter is NULL, data will be written and
- * read using the default codepage for <TT>locale</TT>, unless <TT>locale</TT>
- * is NULL, in which case the system default codepage will be used.
- * @return A new UFILE, or NULL if an error occurred.
- * @draft 3.0
- */
-U_DRAFT UFILE* U_EXPORT2
-u_finit(FILE        *f,
-    const char    *locale,
-    const char    *codepage);
-
-/**
- * Create a UFILE that can be used for localized formatting or parsing.
- * The u_sprintf and u_sscanf functions do not read or write numbers for a
- * specific locale. The ustdio.h file functions can be used on this UFILE.
- * The string is usable once u_fclose or u_fflush has been called on the
- * returned UFILE.
- * @param stringBuf The string used for reading or writing.
- * @param capacity The number of code units available for use in stringBuf
- * @param locale The locale whose conventions will be used to format 
- * and parse output. If this parameter is NULL, the default locale will 
- * be used.
- * @return A new UFILE, or NULL if an error occurred.
- * @draft 3.0
- */
-U_DRAFT UFILE* U_EXPORT2
-u_fstropen(UChar      *stringBuf,
-           int32_t     capacity,
-           const char *locale);
-
-/**
- * Close a UFILE.
- * @param file The UFILE to close.
- * @draft 3.0
- */
-U_DRAFT void U_EXPORT2
-u_fclose(UFILE *file);
-
-/**
- * Tests if the UFILE is at the end of the file stream.
- * @param f The UFILE from which to read.
- * @return Returns TRUE after the first read operation that attempts to
- * read past the end of the file. It returns FALSE if the current position is
- * not end of file.
- * @draft 3.0
-*/
-U_DRAFT UBool U_EXPORT2
-u_feof(UFILE  *f);
-
-/**
- * Flush output of a UFILE. Implies a flush of
- * converter/transliterator state. (That is, a logical break is
- * made in the output stream - for example if a different type of
- * output is desired.)  The underlying OS level file is also flushed.
- * @param file The UFILE to flush.
- * @draft 3.0
- */
-U_DRAFT void U_EXPORT2
-u_fflush(UFILE *file);
-
-/**
- * Rewind the file pointer to the beginning of the file.
- * @param file The UFILE to rewind.
- * @draft 3.0
- */
-U_DRAFT void
-u_frewind(UFILE *file);
-
-/**
- * Get the FILE* associated with a UFILE.
- * @param f The UFILE
- * @return A FILE*, owned by the UFILE.  The FILE <EM>must not</EM> be closed.
- * @draft 3.0
- */
-U_DRAFT FILE* U_EXPORT2
-u_fgetfile(UFILE *f);
-
-#if !UCONFIG_NO_FORMATTING
-
-/**
- * Get the locale whose conventions are used to format and parse output.
- * This is the same locale passed in the preceding call to<TT>u_fsetlocale</TT>
- * or <TT>u_fopen</TT>.
- * @param file The UFILE to set.
- * @return The locale whose conventions are used to format and parse output.
- * @draft 3.0
- */
-U_DRAFT const char* U_EXPORT2
-u_fgetlocale(UFILE *file);
-
-/**
- * Set the locale whose conventions will be used to format and parse output.
- * @param locale The locale whose conventions will be used to format 
- * and parse output.
- * @param file The UFILE to query.
- * @return NULL if successful, otherwise a negative number.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fsetlocale(UFILE      *file,
-             const char *locale);
-
-#endif
-
-/**
- * Get the codepage in which data is written to and read from the UFILE.
- * This is the same codepage passed in the preceding call to 
- * <TT>u_fsetcodepage</TT> or <TT>u_fopen</TT>.
- * @param file The UFILE to query.
- * @return The codepage in which data is written to and read from the UFILE,
- * or NULL if an error occurred.
- * @draft 3.0
- */
-U_DRAFT const char* U_EXPORT2
-u_fgetcodepage(UFILE *file);
-
-/**
- * Set the codepage in which data will be written to and read from the UFILE.
- * All Unicode data written to the UFILE will be converted to this codepage
- * before it is written to the underlying FILE*. It it generally a bad idea to
- * mix codepages within a file. This should only be called right
- * after opening the <TT>UFile</TT>, or after calling <TT>u_frewind</TT>.
- * @param codepage The codepage in which data will be written to 
- * and read from the file. For example <TT>"latin-1"</TT> or <TT>"ibm-943</TT>.
- * A value of NULL means the default codepage for the UFILE's current 
- * locale will be used.
- * @param file The UFILE to set.
- * @return 0 if successful, otherwise a negative number.
- * @see u_frewind
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fsetcodepage(const char   *codepage,
-               UFILE        *file);
-
-
-/**
- * Returns an alias to the converter being used for this file.
- * @param f The UFILE to get the value from
- * @return alias to the converter
- * @draft 3.0
- */
-U_DRAFT UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
-
-#if !UCONFIG_NO_FORMATTING
-
-/* Output functions */
-
-/**
- * Write formatted data to a UFILE.
- * @param f The UFILE to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fprintf(UFILE         *f,
-          const char    *patternSpecification,
-          ... );
-
-/**
- * Write formatted data to a UFILE.
- * This is identical to <TT>u_fprintf</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- * @param f The UFILE to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @see u_fprintf
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vfprintf(UFILE        *f,
-           const char   *patternSpecification,
-           va_list      ap);
-
-/**
- * Write formatted data to a UFILE.
- * @param f The UFILE to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fprintf_u(UFILE       *f,
-            const UChar *patternSpecification,
-            ... );
-
-/**
- * Write formatted data to a UFILE.
- * This is identical to <TT>u_fprintf_u</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- * @param f The UFILE to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @see u_fprintf_u
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vfprintf_u(UFILE      *f,
-            const UChar *patternSpecification,
-            va_list     ap);
-#endif
-/**
- * Write a Unicode to a UFILE.  The null (U+0000) terminated UChar*
- * <TT>s</TT> will be written to <TT>f</TT>, excluding the NULL terminator.
- * A newline will be added to <TT>f</TT>.
- * @param s The UChar* to write.
- * @param f The UFILE to which to write.
- * @return A non-negative number if successful, EOF otherwise.
- * @see u_file_write
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fputs(const UChar *s,
-        UFILE       *f);
-
-/**
- * Write a UChar to a UFILE.
- * @param uc The UChar to write.
- * @param f The UFILE to which to write.
- * @return The character written if successful, EOF otherwise.
- * @draft 3.0
- */
-U_DRAFT UChar32 U_EXPORT2
-u_fputc(UChar32  uc,
-        UFILE  *f);
-
-/**
- * Write Unicode to a UFILE.
- * The ustring passed in will be converted to the UFILE's underlying
- * codepage before it is written.
- * @param ustring A pointer to the Unicode data to write.
- * @param count The number of Unicode characters to write
- * @param f The UFILE to which to write.
- * @return The number of Unicode characters written.
- * @see u_fputs
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_file_write(const UChar    *ustring, 
-             int32_t        count, 
-             UFILE          *f);
-
-
-/* Input functions */
-#if !UCONFIG_NO_FORMATTING
-
-/**
- * Read formatted data from a UFILE.
- * @param f The UFILE from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fscanf(UFILE      *f,
-         const char *patternSpecification,
-         ... );
-
-/**
- * Read formatted data from a UFILE.
- * This is identical to <TT>u_fscanf</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- * @param f The UFILE from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @param ap The argument list to use.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @see u_fscanf
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vfscanf(UFILE         *f,
-          const char    *patternSpecification,
-          va_list        ap);
-
-/**
- * Read formatted data from a UFILE.
- * @param f The UFILE from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_fscanf_u(UFILE        *f,
-           const UChar  *patternSpecification,
-           ... );
-
-/**
- * Read formatted data from a UFILE.
- * This is identical to <TT>u_fscanf_u</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- * @param f The UFILE from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @param ap The argument list to use.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @see u_fscanf_u
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vfscanf_u(UFILE       *f,
-            const UChar *patternSpecification,
-            va_list      ap);
-#endif
-
-/**
- * Read one line of text into a UChar* string from a UFILE. The newline
- * at the end of the line is read into the string. The string is always
- * null terminated
- * @param f The UFILE from which to read.
- * @param n The maximum number of characters - 1 to read.
- * @param s The UChar* to receive the read data.  Characters will be
- * stored successively in <TT>s</TT> until a newline or EOF is
- * reached. A null character (U+0000) will be appended to <TT>s</TT>.
- * @return A pointer to <TT>s</TT>, or NULL if no characters were available.
- * @draft 3.0
- */
-U_DRAFT UChar* U_EXPORT2
-u_fgets(UChar  *s,
-        int32_t n,
-        UFILE  *f);
-
-/**
- * Read a UChar from a UFILE. It is recommended that <TT>u_fgetcx</TT>
- * used instead for proper parsing functions, but sometimes reading
- * code units is needed instead of codepoints.
- *
- * @param f The UFILE from which to read.
- * @return The UChar value read, or U+FFFF if no character was available.
- * @draft 3.0
- */
-U_DRAFT UChar U_EXPORT2
-u_fgetc(UFILE   *f);
-
-/**
- * Read a UChar32 from a UFILE.
- *
- * @param f The UFILE from which to read.
- * @return The UChar32 value read, or U_EOF if no character was
- * available, or U+FFFFFFFF if an ill-formed character was
- * encountered.
- * @see u_unescape()
- * @draft 3.0
- */
-U_DRAFT UChar32 U_EXPORT2
-u_fgetcx(UFILE  *f);
-
-/**
- * Unget a UChar from a UFILE.
- * If this function is not the first to operate on <TT>f</TT> after a call
- * to <TT>u_fgetc</TT>, the results are undefined.
- * If this function is passed a character that was not recieved from the
- * previous <TT>u_fgetc</TT> or <TT>u_fgetcx</TT> call, the results are undefined.
- * @param c The UChar to put back on the stream.
- * @param f The UFILE to receive <TT>c</TT>.
- * @return The UChar32 value put back if successful, U_EOF otherwise.
- * @draft 3.0
- */
-U_DRAFT UChar32 U_EXPORT2
-u_fungetc(UChar32   c,
-      UFILE        *f);
-
-/**
- * Read Unicode from a UFILE.
- * Bytes will be converted from the UFILE's underlying codepage, with
- * subsequent conversion to Unicode. The data will not be NULL terminated.
- * @param chars A pointer to receive the Unicode data.
- * @param count The number of Unicode characters to read.
- * @param f The UFILE from which to read.
- * @return The number of Unicode characters read.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_file_read(UChar        *chars, 
-        int32_t        count, 
-        UFILE         *f);
-
-#if !UCONFIG_NO_TRANSLITERATION
-
-/**
- * Set a transliterator on the UFILE. The transliterator will be owned by the
- * UFILE. 
- * @param file The UFILE to set transliteration on
- * @param adopt The UTransliterator to set. Can be NULL, which will
- * mean that no transliteration is used.
- * @param direction either U_READ, U_WRITE, or U_READWRITE - sets
- *  which direction the transliterator is to be applied to. If
- * U_READWRITE, the "Read" transliteration will be in the inverse
- * direction.
- * @param status ICU error code.
- * @return The previously set transliterator, owned by the
- * caller. If U_READWRITE is specified, only the WRITE transliterator
- * is returned. In most cases, the caller should call utrans_close()
- * on the result of this function.
- * @draft 3.0
- */
-U_DRAFT UTransliterator* U_EXPORT2
-u_fsettransliterator(UFILE *file, UFileDirection direction,
-                     UTransliterator *adopt, UErrorCode *status);
-
-#endif
-
-
-/* Output string functions */
-#if !UCONFIG_NO_FORMATTING
-
-
-/**
- * Write formatted data to a Unicode string.
- *
- * @param buffer The Unicode String to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode code units written to <TT>buffer</TT>. This
- * does not include the terminating null character.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_sprintf(UChar       *buffer,
-        const char    *patternSpecification,
-        ... );
-
-/**
- * Write formatted data to a Unicode string. When the number of code units
- * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
- * units of data are stored in <TT>buffer</TT> and a negative value is
- * returned. When the number of code units required to store the data equals
- * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
- * returned.
- *
- * @param buffer The Unicode String to which to write.
- * @param count The number of code units to read.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode code units written to <TT>buffer</TT>. This
- * does not include the terminating null character.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_snprintf(UChar      *buffer,
-        int32_t       count,
-        const char    *patternSpecification,
-        ... );
-
-/**
- * Write formatted data to a Unicode string.
- * This is identical to <TT>u_sprintf</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- *
- * @param buffer The Unicode string to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>buffer</TT>.
- * @see u_sprintf
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsprintf(UChar      *buffer,
-        const char    *patternSpecification,
-        va_list        ap);
-
-/**
- * Write formatted data to a Unicode string.
- * This is identical to <TT>u_snprintf</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.<br><br>
- * When the number of code units required to store the data exceeds
- * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
- * <TT>buffer</TT> and a negative value is returned. When the number of code
- * units required to store the data equals <TT>count</TT>, the string is not
- * null terminated and <TT>count</TT> is returned.
- *
- * @param buffer The Unicode string to which to write.
- * @param count The number of code units to read.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>buffer</TT>.
- * @see u_sprintf
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsnprintf(UChar     *buffer,
-        int32_t       count,
-        const char    *patternSpecification,
-        va_list        ap);
-
-/**
- * Write formatted data to a Unicode string.
- *
- * @param buffer The Unicode string to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode characters written to <TT>buffer</TT>.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_sprintf_u(UChar      *buffer,
-        const UChar    *patternSpecification,
-        ... );
-
-/**
- * Write formatted data to a Unicode string. When the number of code units
- * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
- * units of data are stored in <TT>buffer</TT> and a negative value is
- * returned. When the number of code units required to store the data equals
- * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
- * returned.
- *
- * @param buffer The Unicode string to which to write.
- * @param count The number of code units to read.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @return The number of Unicode characters written to <TT>buffer</TT>.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_snprintf_u(UChar     *buffer,
-        int32_t        count,
-        const UChar    *patternSpecification,
-        ... );
-
-/**
- * Write formatted data to a Unicode string.
- * This is identical to <TT>u_sprintf_u</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- *
- * @param buffer The Unicode string to which to write.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @see u_sprintf_u
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsprintf_u(UChar     *buffer,
-        const UChar    *patternSpecification,
-        va_list        ap);
-
-/**
- * Write formatted data to a Unicode string.
- * This is identical to <TT>u_snprintf_u</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- * When the number of code units required to store the data exceeds
- * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
- * <TT>buffer</TT> and a negative value is returned. When the number of code
- * units required to store the data equals <TT>count</TT>, the string is not
- * null terminated and <TT>count</TT> is returned.
- *
- * @param buffer The Unicode string to which to write.
- * @param count The number of code units to read.
- * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
- * interpret the variable arguments received and format the data.
- * @param ap The argument list to use.
- * @return The number of Unicode characters written to <TT>f</TT>.
- * @see u_sprintf_u
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsnprintf_u(UChar *buffer,
-        int32_t         count,
-        const UChar     *patternSpecification,
-        va_list         ap);
-
-/* Input string functions */
-
-/**
- * Read formatted data from a Unicode string.
- *
- * @param buffer The Unicode string from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_sscanf(const UChar   *buffer,
-        const char     *patternSpecification,
-        ... );
-
-/**
- * Read formatted data from a Unicode string.
- * This is identical to <TT>u_sscanf</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- *
- * @param buffer The Unicode string from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @param ap The argument list to use.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @see u_sscanf
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsscanf(const UChar  *buffer,
-        const char     *patternSpecification,
-        va_list        ap);
-
-/**
- * Read formatted data from a Unicode string.
- *
- * @param buffer The Unicode string from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_sscanf_u(const UChar  *buffer,
-        const UChar     *patternSpecification,
-        ... );
-
-/**
- * Read formatted data from a Unicode string.
- * This is identical to <TT>u_sscanf_u</TT>, except that it will
- * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
- *
- * @param buffer The Unicode string from which to read.
- * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
- * interpret the variable arguments received and parse the data.
- * @param ap The argument list to use.
- * @return The number of items successfully converted and assigned, or EOF
- * if an error occurred.
- * @see u_sscanf_u
- * @draft 3.0
- */
-U_DRAFT int32_t U_EXPORT2
-u_vsscanf_u(const UChar *buffer,
-        const UChar     *patternSpecification,
-        va_list         ap);
-
-#endif
-#endif
-
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ustdio.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   10/16/98    stephen     Creation.
+*   11/06/98    stephen     Modified per code review.
+*   03/12/99    stephen     Modified for new C API.
+*   07/19/99    stephen     Minor doc update.
+*   02/01/01    george      Added sprintf & sscanf with all of its variants
+******************************************************************************
+*/
+
+#ifndef USTDIO_H
+#define USTDIO_H
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include "unicode/utypes.h"
+#include "unicode/ucnv.h"
+#include "unicode/utrans.h"
+
+/*
+    TODO
+ The following is a small list as to what is currently wrong/suggestions for
+ ustdio.
+
+ * Make sure that * in the scanf format specification works for all formats.
+ * Each UFILE takes up at least 2KB.
+    Look into adding setvbuf() for configurable buffers.
+ * This library does buffering. The OS should do this for us already. Check on
+    this, and remove it from this library, if this is the case. Double buffering
+    wastes a lot of time and space.
+ * Test stdin and stdout with the u_f* functions
+ * Testing should be done for reading and writing multi-byte encodings,
+    and make sure that a character that is contained across buffer boundries
+    works even for incomplete characters.
+ * Make sure that the last character is flushed when the file/string is closed.
+ * snprintf should follow the C99 standard for the return value, which is
+    return the number of characters (excluding the trailing '\0')
+    which would have been written to the destination string regardless
+    of available space. This is like pre-flighting.
+ * Everything that uses %s should do what operator>> does for UnicodeString.
+    It should convert one byte at a time, and once a character is
+    converted then check to see if it's whitespace or in the scanset.
+    If it's whitespace or in the scanset, put all the bytes back (do nothing
+    for sprintf/sscanf).
+ * If bad string data is encountered, make sure that the function fails
+    without memory leaks and the unconvertable characters are valid
+    substitution or are escaped characters.
+ * u_fungetc() can't unget a character when it's at the beginning of the
+    internal conversion buffer. For example, read the buffer size # of
+    characters, and then ungetc to get the previous character that was
+    at the end of the last buffer.
+ * u_fflush() and u_fclose should return an int32_t like C99 functions.
+    0 is returned if the operation was successful and EOF otherwise.
+ * u_fsettransliterator does not support U_READ side of transliteration.
+ * The format specifier should limit the size of a format or honor it in
+    order to prevent buffer overruns.  (e.g. %256.256d).
+ * u_fread and u_fwrite don't exist. They're needed for reading and writing
+    data structures without any conversion.
+ * u_file_read and u_file_write are used for writing strings. u_fgets and
+    u_fputs or u_fread and u_fwrite should be used to do this.
+ * The width parameter for all scanf formats, including scanset, needs
+    better testing. This prevents buffer overflows.
+ * Figure out what is suppose to happen when a codepage is changed midstream.
+    Maybe a flush or a rewind are good enough.
+ * Make sure that a UFile opened with "rw" can be used after using
+    u_fflush with a u_frewind.
+ * scanf(%i) should detect what type of number to use.
+ * Add more testing of the alternate format, %#
+ * Look at newline handling of fputs/puts
+ * Think more about codeunit/codepoint error handling/support in %S,%s,%C,%c,%[]
+ * Complete the file documentation with proper doxygen formatting.
+    See http://oss.software.ibm.com/pipermail/icu/2003-July/005647.html
+*/
+
+/**
+ * \file
+ * \brief C API: Unicode stdio-like API
+ *
+ * <h2>Unicode stdio-like C API</h2>
+ *
+ * <p>This API provides an stdio-like API wrapper around ICU's other
+ * formatting and parsing APIs. It is meant to ease the transition of adding
+ * Unicode support to a preexisting applications using stdio. The following
+ * is a small list of noticable differences between stdio and ICU I/O's
+ * ustdio implementation.</p>
+ *
+ * <ul>
+ * <li>Locale specific formatting and parsing is only done with file IO.</li>
+ * <li>u_fstropen can be used to simulate file IO with strings.
+ * This is similar to the iostream API, and it allows locale specific
+ * formatting and parsing to be used.</li>
+ * <li>This API provides uniform formatting and parsing behavior between
+ * platforms (unlike the standard stdio implementations found on various
+ * platforms).</li>
+ * <li>This API is better suited for text data handling than binary data
+ * handling when compared to the typical stdio implementation.</li>
+ * <li>You can specify a Transliterator while using the file IO.</li>
+ * <li>You can specify a file's codepage separately from the default
+ * system codepage.</li>
+ * </ul>
+ *
+ * <h2>Formatting and Parsing Specification</h2>
+ *
+ * General printf format:<br>
+ * %[format modifier][width][.precision][type modifier][format]
+ * 
+ * General scanf format:<br>
+ * %[*][format modifier][width][type modifier][format]
+ * 
+<table cellspacing="3">
+<tr><td>format</td><td>default<br>printf<br>type</td><td>default<br>scanf<br>type</td><td>description</td></tr>
+<tr><td>%E</td><td>double</td><td>float</td><td>Scientific with an uppercase exponent</td></tr>
+<tr><td>%e</td><td>double</td><td>float</td><td>Scientific with a lowercase exponent</td></tr>
+<tr><td>%G</td><td>double</td><td>float</td><td>Use %E or %f for best format</td></tr>
+<tr><td>%g</td><td>double</td><td>float</td><td>Use %e or %f for best format</td></tr>
+<tr><td>%f</td><td>double</td><td>float</td><td>Simple floating point without the exponent</td></tr>
+<tr><td>%X</td><td>int32_t</td><td>int32_t</td><td>ustdio special uppercase hex radix formatting</td></tr>
+<tr><td>%x</td><td>int32_t</td><td>int32_t</td><td>ustdio special lowercase hex radix formatting</td></tr>
+<tr><td>%d</td><td>int32_t</td><td>int32_t</td><td>Decimal format</td></tr>
+<tr><td>%i</td><td>int32_t</td><td>int32_t</td><td>Same as %d</td></tr>
+<tr><td>%n</td><td>int32_t</td><td>int32_t</td><td>count (write the number of UTF-16 codeunits read/written)</td></tr>
+<tr><td>%o</td><td>int32_t</td><td>int32_t</td><td>ustdio special octal radix formatting</td></tr>
+<tr><td>%u</td><td>uint32_t</td><td>uint32_t</td><td>Decimal format</td></tr>
+<tr><td>%p</td><td>void *</td><td>void *</td><td>Prints the pointer value</td></tr>
+<tr><td>%s</td><td>char *</td><td>char *</td><td>Use default converter or specified converter from fopen</td></tr>
+<tr><td>%c</td><td>char</td><td>char</td><td>Use default converter or specified converter from fopen<br>
+When width is specified for scanf, this acts like a non-NULL-terminated char * string.<br>
+By default, only one char is written.</td></tr>
+<tr><td>%S</td><td>UChar *</td><td>UChar *</td><td>Null terminated UTF-16 string</td></tr>
+<tr><td>%C</td><td>UChar</td><td>UChar</td><td>16-bit Unicode code unit<br>
+When width is specified for scanf, this acts like a non-NULL-terminated UChar * string<br>
+By default, only one codepoint is written.</td></tr>
+<tr><td>%[]</td><td>&nbsp;</td><td>UChar *</td><td>Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet</td></tr>
+<tr><td>%%</td><td>&nbsp;</td><td>&nbsp;</td><td>Show a percent sign</td></tr>
+</table>
+
+Format modifiers
+<table>
+<tr><td>modifier</td><td>formats</td><td>type</td><td>comments</td></tr>
+<tr><td>%h</td><td>%d, %i, %o, %x</td><td>int16_t</td><td>short format</td></tr>
+<tr><td>%h</td><td>%u</td><td>uint16_t</td><td>short format</td></tr>
+<tr><td>%h</td><td>c</td><td>char</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
+<tr><td>%h</td><td>s</td><td>char *</td><td><b>(Unimplemented)</b> Use invariant converter</td></tr>
+<tr><td>%h</td><td>C</td><td>char</td><td><b>(Unimplemented)</b> 8-bit Unicode code unit</td></tr>
+<tr><td>%h</td><td>S</td><td>char *</td><td><b>(Unimplemented)</b> Null terminated UTF-8 string</td></tr>
+<tr><td>%l</td><td>%d, %i, %o, %x</td><td>int32_t</td><td>long format (no effect)</td></tr>
+<tr><td>%l</td><td>%u</td><td>uint32_t</td><td>long format (no effect)</td></tr>
+<tr><td>%l</td><td>c</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
+<tr><td>%l</td><td>s</td><td>N/A</td><td><b>(Unimplemented)</b> Reserved for future implementation</td></tr>
+<tr><td>%l</td><td>C</td><td>UChar32</td><td><b>(Unimplemented)</b> 32-bit Unicode code unit</td></tr>
+<tr><td>%l</td><td>S</td><td>UChar32 *</td><td><b>(Unimplemented)</b> Null terminated UTF-32 string</td></tr>
+<tr><td>%ll</td><td>%d, %i, %o, %x</td><td>int64_t</td><td>long long format</td></tr>
+<tr><td>%ll</td><td>%u</td><td>uint64_t</td><td><b>(Unimplemented)</b> long long format</td></tr>
+<tr><td>%-</td><td><i>all</i></td><td>N/A</td><td>Left justify</td></tr>
+<tr><td>%+</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Always show the plus or minus sign. Needs data for plus sign.</td></tr>
+<tr><td>% </td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Instead of a "+" output a blank character for positive numbers.</td></tr>
+<tr><td>%#</td><td>%d, %i, %o, %x, %e, %f, %g, %E, %G</td><td>N/A</td><td>Precede octal value with 0, hex with 0x and show the 
+                decimal point for floats.</td></tr>
+<tr><td>%<i>n</i></td><td><i>all</i></td><td>N/A</td><td>Width of input/output. num is an actual number from 0 to 
+                some large number.</td></tr>
+<tr><td>%.<i>n</i></td><td>%e, %f, %g, %E, %F, %G</td><td>N/A</td><td>Significant digits precision. num is an actual number from
+                0 to some large number.<br>If * is used in printf, then the precision is passed in as an argument before the number to be formatted.</td></tr>
+</table>
+
+printf modifier
+%*  int32_t     Next argument after this one specifies the width
+
+scanf modifier
+%*  N/A         This field is scanned, but not stored
+
+ */
+
+
+/**
+ * When an end of file is encountered, this value can be returned.
+ * @see u_fgetc
+ * @stable 3.0
+ */
+#define U_EOF 0xFFFF
+
+/** Forward declaration of a Unicode-aware file @stable 3.0 */
+typedef struct UFILE UFILE;
+
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Enum for which direction of stream a transliterator applies to.
+ * @see u_fsettransliterator
+ * @draft 3.0
+ */
+typedef enum { 
+   U_READ = 1,
+   U_WRITE = 2, 
+   U_READWRITE =3  /* == (U_READ | U_WRITE) */ 
+} UFileDirection;
+
+#endif /* U_HIDE_DRAFT_API */
+
+/**
+ * Open a UFILE.
+ * A UFILE is a wrapper around a FILE* that is locale and codepage aware.
+ * That is, data written to a UFILE will be formatted using the conventions
+ * specified by that UFILE's Locale; this data will be in the character set
+ * specified by that UFILE's codepage.
+ * @param filename The name of the file to open.
+ * @param perm The read/write permission for the UFILE; one of "r", "w", "rw"
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @param codepage The codepage in which data will be written to and
+ * read from the file. If this paramter is NULL the system default codepage
+ * will be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_fopen(const char    *filename,
+    const char    *perm,
+    const char    *locale,
+    const char    *codepage);
+
+/**
+ * Open a UFILE on top of an existing FILE* stream.
+ * @param f The FILE* to which this UFILE will attach.
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @param codepage The codepage in which data will be written to and
+ * read from the file. If this paramter is NULL, data will be written and
+ * read using the default codepage for <TT>locale</TT>, unless <TT>locale</TT>
+ * is NULL, in which case the system default codepage will be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_finit(FILE        *f,
+    const char    *locale,
+    const char    *codepage);
+
+/**
+ * Create a UFILE that can be used for localized formatting or parsing.
+ * The u_sprintf and u_sscanf functions do not read or write numbers for a
+ * specific locale. The ustdio.h file functions can be used on this UFILE.
+ * The string is usable once u_fclose or u_fflush has been called on the
+ * returned UFILE.
+ * @param stringBuf The string used for reading or writing.
+ * @param capacity The number of code units available for use in stringBuf
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output. If this parameter is NULL, the default locale will 
+ * be used.
+ * @return A new UFILE, or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT UFILE* U_EXPORT2
+u_fstropen(UChar      *stringBuf,
+           int32_t     capacity,
+           const char *locale);
+
+/**
+ * Close a UFILE.
+ * @param file The UFILE to close.
+ * @draft 3.0
+ */
+U_DRAFT void U_EXPORT2
+u_fclose(UFILE *file);
+
+/**
+ * Tests if the UFILE is at the end of the file stream.
+ * @param f The UFILE from which to read.
+ * @return Returns TRUE after the first read operation that attempts to
+ * read past the end of the file. It returns FALSE if the current position is
+ * not end of file.
+ * @draft 3.0
+*/
+U_DRAFT UBool U_EXPORT2
+u_feof(UFILE  *f);
+
+/**
+ * Flush output of a UFILE. Implies a flush of
+ * converter/transliterator state. (That is, a logical break is
+ * made in the output stream - for example if a different type of
+ * output is desired.)  The underlying OS level file is also flushed.
+ * @param file The UFILE to flush.
+ * @draft 3.0
+ */
+U_DRAFT void U_EXPORT2
+u_fflush(UFILE *file);
+
+/**
+ * Rewind the file pointer to the beginning of the file.
+ * @param file The UFILE to rewind.
+ * @draft 3.0
+ */
+U_DRAFT void
+u_frewind(UFILE *file);
+
+/**
+ * Get the FILE* associated with a UFILE.
+ * @param f The UFILE
+ * @return A FILE*, owned by the UFILE.  The FILE <EM>must not</EM> be closed.
+ * @draft 3.0
+ */
+U_DRAFT FILE* U_EXPORT2
+u_fgetfile(UFILE *f);
+
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * Get the locale whose conventions are used to format and parse output.
+ * This is the same locale passed in the preceding call to<TT>u_fsetlocale</TT>
+ * or <TT>u_fopen</TT>.
+ * @param file The UFILE to set.
+ * @return The locale whose conventions are used to format and parse output.
+ * @draft 3.0
+ */
+U_DRAFT const char* U_EXPORT2
+u_fgetlocale(UFILE *file);
+
+/**
+ * Set the locale whose conventions will be used to format and parse output.
+ * @param locale The locale whose conventions will be used to format 
+ * and parse output.
+ * @param file The UFILE to query.
+ * @return NULL if successful, otherwise a negative number.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fsetlocale(UFILE      *file,
+             const char *locale);
+
+#endif
+
+/**
+ * Get the codepage in which data is written to and read from the UFILE.
+ * This is the same codepage passed in the preceding call to 
+ * <TT>u_fsetcodepage</TT> or <TT>u_fopen</TT>.
+ * @param file The UFILE to query.
+ * @return The codepage in which data is written to and read from the UFILE,
+ * or NULL if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT const char* U_EXPORT2
+u_fgetcodepage(UFILE *file);
+
+/**
+ * Set the codepage in which data will be written to and read from the UFILE.
+ * All Unicode data written to the UFILE will be converted to this codepage
+ * before it is written to the underlying FILE*. It it generally a bad idea to
+ * mix codepages within a file. This should only be called right
+ * after opening the <TT>UFile</TT>, or after calling <TT>u_frewind</TT>.
+ * @param codepage The codepage in which data will be written to 
+ * and read from the file. For example <TT>"latin-1"</TT> or <TT>"ibm-943</TT>.
+ * A value of NULL means the default codepage for the UFILE's current 
+ * locale will be used.
+ * @param file The UFILE to set.
+ * @return 0 if successful, otherwise a negative number.
+ * @see u_frewind
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fsetcodepage(const char   *codepage,
+               UFILE        *file);
+
+
+/**
+ * Returns an alias to the converter being used for this file.
+ * @param f The UFILE to get the value from
+ * @return alias to the converter
+ * @draft 3.0
+ */
+U_DRAFT UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
+
+#if !UCONFIG_NO_FORMATTING
+
+/* Output functions */
+
+/**
+ * Write formatted data to a UFILE.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fprintf(UFILE         *f,
+          const char    *patternSpecification,
+          ... );
+
+/**
+ * Write formatted data to a UFILE.
+ * This is identical to <TT>u_fprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_fprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfprintf(UFILE        *f,
+           const char   *patternSpecification,
+           va_list      ap);
+
+/**
+ * Write formatted data to a UFILE.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fprintf_u(UFILE       *f,
+            const UChar *patternSpecification,
+            ... );
+
+/**
+ * Write formatted data to a UFILE.
+ * This is identical to <TT>u_fprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_fprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_fprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfprintf_u(UFILE      *f,
+            const UChar *patternSpecification,
+            va_list     ap);
+#endif
+/**
+ * Write a Unicode to a UFILE.  The null (U+0000) terminated UChar*
+ * <TT>s</TT> will be written to <TT>f</TT>, excluding the NULL terminator.
+ * A newline will be added to <TT>f</TT>.
+ * @param s The UChar* to write.
+ * @param f The UFILE to which to write.
+ * @return A non-negative number if successful, EOF otherwise.
+ * @see u_file_write
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fputs(const UChar *s,
+        UFILE       *f);
+
+/**
+ * Write a UChar to a UFILE.
+ * @param uc The UChar to write.
+ * @param f The UFILE to which to write.
+ * @return The character written if successful, EOF otherwise.
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fputc(UChar32  uc,
+        UFILE  *f);
+
+/**
+ * Write Unicode to a UFILE.
+ * The ustring passed in will be converted to the UFILE's underlying
+ * codepage before it is written.
+ * @param ustring A pointer to the Unicode data to write.
+ * @param count The number of Unicode characters to write
+ * @param f The UFILE to which to write.
+ * @return The number of Unicode characters written.
+ * @see u_fputs
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_file_write(const UChar    *ustring, 
+             int32_t        count, 
+             UFILE          *f);
+
+
+/* Input functions */
+#if !UCONFIG_NO_FORMATTING
+
+/**
+ * Read formatted data from a UFILE.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fscanf(UFILE      *f,
+         const char *patternSpecification,
+         ... );
+
+/**
+ * Read formatted data from a UFILE.
+ * This is identical to <TT>u_fscanf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_fscanf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfscanf(UFILE         *f,
+          const char    *patternSpecification,
+          va_list        ap);
+
+/**
+ * Read formatted data from a UFILE.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_fscanf_u(UFILE        *f,
+           const UChar  *patternSpecification,
+           ... );
+
+/**
+ * Read formatted data from a UFILE.
+ * This is identical to <TT>u_fscanf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * @param f The UFILE from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_fscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_fscanf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vfscanf_u(UFILE       *f,
+            const UChar *patternSpecification,
+            va_list      ap);
+#endif
+
+/**
+ * Read one line of text into a UChar* string from a UFILE. The newline
+ * at the end of the line is read into the string. The string is always
+ * null terminated
+ * @param f The UFILE from which to read.
+ * @param n The maximum number of characters - 1 to read.
+ * @param s The UChar* to receive the read data.  Characters will be
+ * stored successively in <TT>s</TT> until a newline or EOF is
+ * reached. A null character (U+0000) will be appended to <TT>s</TT>.
+ * @return A pointer to <TT>s</TT>, or NULL if no characters were available.
+ * @draft 3.0
+ */
+U_DRAFT UChar* U_EXPORT2
+u_fgets(UChar  *s,
+        int32_t n,
+        UFILE  *f);
+
+/**
+ * Read a UChar from a UFILE. It is recommended that <TT>u_fgetcx</TT>
+ * used instead for proper parsing functions, but sometimes reading
+ * code units is needed instead of codepoints.
+ *
+ * @param f The UFILE from which to read.
+ * @return The UChar value read, or U+FFFF if no character was available.
+ * @draft 3.0
+ */
+U_DRAFT UChar U_EXPORT2
+u_fgetc(UFILE   *f);
+
+/**
+ * Read a UChar32 from a UFILE.
+ *
+ * @param f The UFILE from which to read.
+ * @return The UChar32 value read, or U_EOF if no character was
+ * available, or U+FFFFFFFF if an ill-formed character was
+ * encountered.
+ * @see u_unescape()
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fgetcx(UFILE  *f);
+
+/**
+ * Unget a UChar from a UFILE.
+ * If this function is not the first to operate on <TT>f</TT> after a call
+ * to <TT>u_fgetc</TT>, the results are undefined.
+ * If this function is passed a character that was not recieved from the
+ * previous <TT>u_fgetc</TT> or <TT>u_fgetcx</TT> call, the results are undefined.
+ * @param c The UChar to put back on the stream.
+ * @param f The UFILE to receive <TT>c</TT>.
+ * @return The UChar32 value put back if successful, U_EOF otherwise.
+ * @draft 3.0
+ */
+U_DRAFT UChar32 U_EXPORT2
+u_fungetc(UChar32   c,
+      UFILE        *f);
+
+/**
+ * Read Unicode from a UFILE.
+ * Bytes will be converted from the UFILE's underlying codepage, with
+ * subsequent conversion to Unicode. The data will not be NULL terminated.
+ * @param chars A pointer to receive the Unicode data.
+ * @param count The number of Unicode characters to read.
+ * @param f The UFILE from which to read.
+ * @return The number of Unicode characters read.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_file_read(UChar        *chars, 
+        int32_t        count, 
+        UFILE         *f);
+
+#if !UCONFIG_NO_TRANSLITERATION
+
+/**
+ * Set a transliterator on the UFILE. The transliterator will be owned by the
+ * UFILE. 
+ * @param file The UFILE to set transliteration on
+ * @param adopt The UTransliterator to set. Can be NULL, which will
+ * mean that no transliteration is used.
+ * @param direction either U_READ, U_WRITE, or U_READWRITE - sets
+ *  which direction the transliterator is to be applied to. If
+ * U_READWRITE, the "Read" transliteration will be in the inverse
+ * direction.
+ * @param status ICU error code.
+ * @return The previously set transliterator, owned by the
+ * caller. If U_READWRITE is specified, only the WRITE transliterator
+ * is returned. In most cases, the caller should call utrans_close()
+ * on the result of this function.
+ * @draft 3.0
+ */
+U_DRAFT UTransliterator* U_EXPORT2
+u_fsettransliterator(UFILE *file, UFileDirection direction,
+                     UTransliterator *adopt, UErrorCode *status);
+
+#endif
+
+
+/* Output string functions */
+#if !UCONFIG_NO_FORMATTING
+
+
+/**
+ * Write formatted data to a Unicode string.
+ *
+ * @param buffer The Unicode String to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode code units written to <TT>buffer</TT>. This
+ * does not include the terminating null character.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sprintf(UChar       *buffer,
+        const char    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string. When the number of code units
+ * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
+ * units of data are stored in <TT>buffer</TT> and a negative value is
+ * returned. When the number of code units required to store the data equals
+ * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
+ * returned.
+ *
+ * @param buffer The Unicode String to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode code units written to <TT>buffer</TT>. This
+ * does not include the terminating null character.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_snprintf(UChar      *buffer,
+        int32_t       count,
+        const char    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_sprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @see u_sprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsprintf(UChar      *buffer,
+        const char    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_snprintf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.<br><br>
+ * When the number of code units required to store the data exceeds
+ * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
+ * <TT>buffer</TT> and a negative value is returned. When the number of code
+ * units required to store the data equals <TT>count</TT>, the string is not
+ * null terminated and <TT>count</TT> is returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @see u_sprintf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsnprintf(UChar     *buffer,
+        int32_t       count,
+        const char    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sprintf_u(UChar      *buffer,
+        const UChar    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string. When the number of code units
+ * required to store the data exceeds <TT>count</TT>, then <TT>count</TT> code
+ * units of data are stored in <TT>buffer</TT> and a negative value is
+ * returned. When the number of code units required to store the data equals
+ * <TT>count</TT>, the string is not null terminated and <TT>count</TT> is
+ * returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>buffer</TT>.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_snprintf_u(UChar     *buffer,
+        int32_t        count,
+        const UChar    *patternSpecification,
+        ... );
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_sprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_sprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsprintf_u(UChar     *buffer,
+        const UChar    *patternSpecification,
+        va_list        ap);
+
+/**
+ * Write formatted data to a Unicode string.
+ * This is identical to <TT>u_snprintf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ * When the number of code units required to store the data exceeds
+ * <TT>count</TT>, then <TT>count</TT> code units of data are stored in
+ * <TT>buffer</TT> and a negative value is returned. When the number of code
+ * units required to store the data equals <TT>count</TT>, the string is not
+ * null terminated and <TT>count</TT> is returned.
+ *
+ * @param buffer The Unicode string to which to write.
+ * @param count The number of code units to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sprintf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @param ap The argument list to use.
+ * @return The number of Unicode characters written to <TT>f</TT>.
+ * @see u_sprintf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsnprintf_u(UChar *buffer,
+        int32_t         count,
+        const UChar     *patternSpecification,
+        va_list         ap);
+
+/* Input string functions */
+
+/**
+ * Read formatted data from a Unicode string.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sscanf(const UChar   *buffer,
+        const char     *patternSpecification,
+        ... );
+
+/**
+ * Read formatted data from a Unicode string.
+ * This is identical to <TT>u_sscanf</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_sscanf
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsscanf(const UChar  *buffer,
+        const char     *patternSpecification,
+        va_list        ap);
+
+/**
+ * Read formatted data from a Unicode string.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_sscanf_u(const UChar  *buffer,
+        const UChar     *patternSpecification,
+        ... );
+
+/**
+ * Read formatted data from a Unicode string.
+ * This is identical to <TT>u_sscanf_u</TT>, except that it will
+ * <EM>not</EM> call <TT>va_start</TT> and <TT>va_end</TT>.
+ *
+ * @param buffer The Unicode string from which to read.
+ * @param patternSpecification A pattern specifying how <TT>u_sscanf</TT> will
+ * interpret the variable arguments received and parse the data.
+ * @param ap The argument list to use.
+ * @return The number of items successfully converted and assigned, or EOF
+ * if an error occurred.
+ * @see u_sscanf_u
+ * @draft 3.0
+ */
+U_DRAFT int32_t U_EXPORT2
+u_vsscanf_u(const UChar *buffer,
+        const UChar     *patternSpecification,
+        va_list         ap);
+
+#endif
+#endif
+
+


Property changes on: trunk/source/io/unicode/ustdio.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/unicode/ustream.h
===================================================================
--- trunk/source/io/unicode/ustream.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/unicode/ustream.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,65 +1,65 @@
-/*
-**********************************************************************
-*   Copyright (C) 2001-2006 International Business Machines
-*   Corporation and others.  All Rights Reserved.
-**********************************************************************
-*  FILE NAME : ustream.h
-*
-*   Modification History:
-*
-*   Date        Name        Description
-*   06/25/2001  grhoten     Move iostream from unistr.h
-******************************************************************************
-*/
-   
-#ifndef USTREAM_H
-#define USTREAM_H
-
-#include "unicode/unistr.h"
-
-/**
- * \file
- * \brief C++ API: Unicode iostream like API
- *
- * At this time, this API is very limited. It contains
- * operator<< and operator>> for UnicodeString manipulation with the
- * C++ I/O stream API.
- */
-
-#if U_IOSTREAM_SOURCE >= 199711
-#include <iostream>
-
-U_NAMESPACE_BEGIN
-
-/**
- * Write the contents of a UnicodeString to a C++ ostream. This functions writes
- * the characters in a UnicodeString to an ostream. The UChars in the
- * UnicodeString are converted to the char based ostream with the default
- * converter.
- * @stable 3.0
- */
-U_IO_API std::ostream & U_EXPORT2 operator<<(std::ostream& stream, const UnicodeString& s);
-
-/**
- * Write the contents from a C++ istream to a UnicodeString. The UChars in the
- * UnicodeString are converted from the char based istream with the default
- * converter.
- * @stable 3.0
- */
-U_IO_API std::istream & U_EXPORT2 operator>>(std::istream& stream, UnicodeString& s);
-U_NAMESPACE_END
-
-#elif U_IOSTREAM_SOURCE >= 198506
-#include <iostream.h>
-
-U_NAMESPACE_BEGIN
-U_IO_API ostream & U_EXPORT2 operator<<(ostream& stream, const UnicodeString& s);
-
-U_IO_API istream & U_EXPORT2 operator>>(istream& stream, UnicodeString& s);
-U_NAMESPACE_END
-
-#endif
-
-/* No operator for UChar because it can conflict with wchar_t  */
-
-#endif
+/*
+**********************************************************************
+*   Copyright (C) 2001-2006 International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*  FILE NAME : ustream.h
+*
+*   Modification History:
+*
+*   Date        Name        Description
+*   06/25/2001  grhoten     Move iostream from unistr.h
+******************************************************************************
+*/
+   
+#ifndef USTREAM_H
+#define USTREAM_H
+
+#include "unicode/unistr.h"
+
+/**
+ * \file
+ * \brief C++ API: Unicode iostream like API
+ *
+ * At this time, this API is very limited. It contains
+ * operator<< and operator>> for UnicodeString manipulation with the
+ * C++ I/O stream API.
+ */
+
+#if U_IOSTREAM_SOURCE >= 199711
+#include <iostream>
+
+U_NAMESPACE_BEGIN
+
+/**
+ * Write the contents of a UnicodeString to a C++ ostream. This functions writes
+ * the characters in a UnicodeString to an ostream. The UChars in the
+ * UnicodeString are converted to the char based ostream with the default
+ * converter.
+ * @stable 3.0
+ */
+U_IO_API std::ostream & U_EXPORT2 operator<<(std::ostream& stream, const UnicodeString& s);
+
+/**
+ * Write the contents from a C++ istream to a UnicodeString. The UChars in the
+ * UnicodeString are converted from the char based istream with the default
+ * converter.
+ * @stable 3.0
+ */
+U_IO_API std::istream & U_EXPORT2 operator>>(std::istream& stream, UnicodeString& s);
+U_NAMESPACE_END
+
+#elif U_IOSTREAM_SOURCE >= 198506
+#include <iostream.h>
+
+U_NAMESPACE_BEGIN
+U_IO_API ostream & U_EXPORT2 operator<<(ostream& stream, const UnicodeString& s);
+
+U_IO_API istream & U_EXPORT2 operator>>(istream& stream, UnicodeString& s);
+U_NAMESPACE_END
+
+#endif
+
+/* No operator for UChar because it can conflict with wchar_t  */
+
+#endif


Property changes on: trunk/source/io/unicode/ustream.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uprintf.c
===================================================================
--- trunk/source/io/uprintf.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uprintf.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,163 +1,163 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File uprintf.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/19/98    stephen     Creation.
-*   03/12/99    stephen     Modified for new C API.
-*                           Added conversion from default codepage.
-*   08/07/2003  george      Reunify printf implementations
-******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "unicode/unum.h"
-#include "unicode/udat.h"
-#include "unicode/putil.h"
-
-#include "uprintf.h"
-#include "ufile.h"
-#include "locbund.h"
-
-#include "cmemory.h"
-
-static int32_t U_EXPORT2
-u_printf_write(void          *context,
-               const UChar   *str,
-               int32_t       count)
-{
-    return u_file_write(str, count, (UFILE *)context);
-}
-
-static int32_t
-u_printf_pad_and_justify(void                        *context,
-                         const u_printf_spec_info    *info,
-                         const UChar                 *result,
-                         int32_t                     resultLen)
-{
-    UFILE   *output = (UFILE *)context;
-    int32_t written, i;
-
-    /* pad and justify, if needed */
-    if(info->fWidth != -1 && resultLen < info->fWidth) {
-        /* left justify */
-        if(info->fLeft) {
-            written = u_file_write(result, resultLen, output);
-            for(i = 0; i < info->fWidth - resultLen; ++i) {
-                written += u_file_write(&info->fPadChar, 1, output);
-            }
-        }
-        /* right justify */
-        else {
-            written = 0;
-            for(i = 0; i < info->fWidth - resultLen; ++i) {
-                written += u_file_write(&info->fPadChar, 1, output);
-            }
-            written += u_file_write(result, resultLen, output);
-        }
-    }
-    /* just write the formatted output */
-    else {
-        written = u_file_write(result, resultLen, output);
-    }
-
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2 
-u_fprintf(    UFILE        *f,
-          const char    *patternSpecification,
-          ... )
-{
-    va_list ap;
-    int32_t count;
-
-    va_start(ap, patternSpecification);
-    count = u_vfprintf(f, patternSpecification, ap);
-    va_end(ap);
-
-    return count;
-}
-
-U_CAPI int32_t U_EXPORT2 
-u_fprintf_u(    UFILE        *f,
-            const UChar    *patternSpecification,
-            ... )
-{
-    va_list ap;
-    int32_t count;
-
-    va_start(ap, patternSpecification);
-    count = u_vfprintf_u(f, patternSpecification, ap);
-    va_end(ap);
-
-    return count;
-}
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vfprintf(    UFILE        *f,
-           const char    *patternSpecification,
-           va_list        ap)
-{
-    int32_t count;
-    UChar *pattern;
-    UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
-    int32_t size = (int32_t)strlen(patternSpecification) + 1;
-
-    /* convert from the default codepage to Unicode */
-    if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
-        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
-        if(pattern == 0) {
-            return 0;
-        }
-    }
-    else {
-        pattern = buffer;
-    }
-    u_charsToUChars(patternSpecification, pattern, size);
-
-    /* do the work */
-    count = u_vfprintf_u(f, pattern, ap);
-
-    /* clean up */
-    if (pattern != buffer) {
-        uprv_free(pattern);
-    }
-
-    return count;
-}
-
-static const u_printf_stream_handler g_stream_handler = {
-    u_printf_write,
-    u_printf_pad_and_justify
-};
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vfprintf_u(    UFILE        *f,
-             const UChar    *patternSpecification,
-             va_list        ap)
-{
-    int32_t          written = 0;   /* haven't written anything yet */
-
-    /* parse and print the whole format string */
-    u_printf_parse(&g_stream_handler, patternSpecification, f, NULL, &f->str.fBundle, &written, ap);
-
-    /* return # of UChars written */
-    return written;
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File uprintf.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/19/98    stephen     Creation.
+*   03/12/99    stephen     Modified for new C API.
+*                           Added conversion from default codepage.
+*   08/07/2003  george      Reunify printf implementations
+******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "unicode/unum.h"
+#include "unicode/udat.h"
+#include "unicode/putil.h"
+
+#include "uprintf.h"
+#include "ufile.h"
+#include "locbund.h"
+
+#include "cmemory.h"
+
+static int32_t U_EXPORT2
+u_printf_write(void          *context,
+               const UChar   *str,
+               int32_t       count)
+{
+    return u_file_write(str, count, (UFILE *)context);
+}
+
+static int32_t
+u_printf_pad_and_justify(void                        *context,
+                         const u_printf_spec_info    *info,
+                         const UChar                 *result,
+                         int32_t                     resultLen)
+{
+    UFILE   *output = (UFILE *)context;
+    int32_t written, i;
+
+    /* pad and justify, if needed */
+    if(info->fWidth != -1 && resultLen < info->fWidth) {
+        /* left justify */
+        if(info->fLeft) {
+            written = u_file_write(result, resultLen, output);
+            for(i = 0; i < info->fWidth - resultLen; ++i) {
+                written += u_file_write(&info->fPadChar, 1, output);
+            }
+        }
+        /* right justify */
+        else {
+            written = 0;
+            for(i = 0; i < info->fWidth - resultLen; ++i) {
+                written += u_file_write(&info->fPadChar, 1, output);
+            }
+            written += u_file_write(result, resultLen, output);
+        }
+    }
+    /* just write the formatted output */
+    else {
+        written = u_file_write(result, resultLen, output);
+    }
+
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2 
+u_fprintf(    UFILE        *f,
+          const char    *patternSpecification,
+          ... )
+{
+    va_list ap;
+    int32_t count;
+
+    va_start(ap, patternSpecification);
+    count = u_vfprintf(f, patternSpecification, ap);
+    va_end(ap);
+
+    return count;
+}
+
+U_CAPI int32_t U_EXPORT2 
+u_fprintf_u(    UFILE        *f,
+            const UChar    *patternSpecification,
+            ... )
+{
+    va_list ap;
+    int32_t count;
+
+    va_start(ap, patternSpecification);
+    count = u_vfprintf_u(f, patternSpecification, ap);
+    va_end(ap);
+
+    return count;
+}
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vfprintf(    UFILE        *f,
+           const char    *patternSpecification,
+           va_list        ap)
+{
+    int32_t count;
+    UChar *pattern;
+    UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
+    int32_t size = (int32_t)strlen(patternSpecification) + 1;
+
+    /* convert from the default codepage to Unicode */
+    if (size >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
+        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+        if(pattern == 0) {
+            return 0;
+        }
+    }
+    else {
+        pattern = buffer;
+    }
+    u_charsToUChars(patternSpecification, pattern, size);
+
+    /* do the work */
+    count = u_vfprintf_u(f, pattern, ap);
+
+    /* clean up */
+    if (pattern != buffer) {
+        uprv_free(pattern);
+    }
+
+    return count;
+}
+
+static const u_printf_stream_handler g_stream_handler = {
+    u_printf_write,
+    u_printf_pad_and_justify
+};
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vfprintf_u(    UFILE        *f,
+             const UChar    *patternSpecification,
+             va_list        ap)
+{
+    int32_t          written = 0;   /* haven't written anything yet */
+
+    /* parse and print the whole format string */
+    u_printf_parse(&g_stream_handler, patternSpecification, f, NULL, &f->str.fBundle, &written, ap);
+
+    /* return # of UChars written */
+    return written;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+


Property changes on: trunk/source/io/uprintf.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uprintf.h
===================================================================
--- trunk/source/io/uprintf.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uprintf.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,101 +1,101 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File uprintf.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/19/98    stephen        Creation.
-*   03/12/99    stephen     Modified for new C API.
-******************************************************************************
-*/
-
-#ifndef UPRINTF_H
-#define UPRINTF_H
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/ustdio.h"
-#include "ufmt_cmn.h"
-#include "locbund.h"
-
-/**
- * Struct encapsulating a single uprintf format specification.
- */
-typedef struct u_printf_spec_info {
-  int32_t    fPrecision;    /* Precision  */
-  int32_t    fWidth;        /* Width  */
-
-  UChar     fOrigSpec;      /* Conversion specification */
-  UChar     fSpec;          /* Conversion specification */
-  UChar     fPadChar;       /* Padding character  */
-
-  UBool     fAlt;           /* # flag  */
-  UBool     fSpace;         /* Space flag  */
-  UBool     fLeft;          /* - flag  */
-  UBool     fShowSign;      /* + flag  */
-  UBool     fZero;          /* 0 flag  */
-
-  UBool     fIsLongDouble;  /* L flag  */
-  UBool     fIsShort;       /* h flag  */
-  UBool     fIsLong;        /* l flag  */
-  UBool     fIsLongLong;    /* ll flag  */
-} u_printf_spec_info;
-
-typedef int32_t U_EXPORT2
-u_printf_write_stream(void          *context,
-                      const UChar   *str,
-                      int32_t       count);
-
-typedef int32_t U_EXPORT2
-u_printf_pad_and_justify_stream(void                        *context,
-                                const u_printf_spec_info    *info,
-                                const UChar                 *result,
-                                int32_t                     resultLen);
-
-typedef struct u_printf_stream_handler {
-    u_printf_write_stream *write;
-    u_printf_pad_and_justify_stream *pad_and_justify;
-} u_printf_stream_handler;
-
-/* Used by sprintf */
-typedef struct u_localized_print_string {
-    UChar     *str;     /* Place to write the string */
-    int32_t   available;/* Number of codeunits available to write to */
-    int32_t   len;      /* Maximum number of code units that can be written to output */
-
-    ULocaleBundle  fBundle;     /* formatters */
-} u_localized_print_string;
-
-#define UP_PERCENT 0x0025
-
-/**
- * Parse a single u_printf format string.
- * @param fmt A pointer to a '%' character in a u_printf format specification.
- * @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed
- * format specifier.
- * @param locStringContext If present, will make sure that it will only write
- *          to the buffer when space is available. It's done this way because
- *          va_list sometimes can't be passed by pointer.
- * @return The number of characters contained in this specifier.
- */
-U_CFUNC int32_t
-u_printf_parse(const u_printf_stream_handler *streamHandler,
-               const UChar     *fmt,
-               void            *context,
-               u_localized_print_string *locStringContext,
-               ULocaleBundle   *formatBundle,
-               int32_t         *written,
-               va_list         ap);
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
-#endif
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File uprintf.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/19/98    stephen        Creation.
+*   03/12/99    stephen     Modified for new C API.
+******************************************************************************
+*/
+
+#ifndef UPRINTF_H
+#define UPRINTF_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ustdio.h"
+#include "ufmt_cmn.h"
+#include "locbund.h"
+
+/**
+ * Struct encapsulating a single uprintf format specification.
+ */
+typedef struct u_printf_spec_info {
+  int32_t    fPrecision;    /* Precision  */
+  int32_t    fWidth;        /* Width  */
+
+  UChar     fOrigSpec;      /* Conversion specification */
+  UChar     fSpec;          /* Conversion specification */
+  UChar     fPadChar;       /* Padding character  */
+
+  UBool     fAlt;           /* # flag  */
+  UBool     fSpace;         /* Space flag  */
+  UBool     fLeft;          /* - flag  */
+  UBool     fShowSign;      /* + flag  */
+  UBool     fZero;          /* 0 flag  */
+
+  UBool     fIsLongDouble;  /* L flag  */
+  UBool     fIsShort;       /* h flag  */
+  UBool     fIsLong;        /* l flag  */
+  UBool     fIsLongLong;    /* ll flag  */
+} u_printf_spec_info;
+
+typedef int32_t U_EXPORT2
+u_printf_write_stream(void          *context,
+                      const UChar   *str,
+                      int32_t       count);
+
+typedef int32_t U_EXPORT2
+u_printf_pad_and_justify_stream(void                        *context,
+                                const u_printf_spec_info    *info,
+                                const UChar                 *result,
+                                int32_t                     resultLen);
+
+typedef struct u_printf_stream_handler {
+    u_printf_write_stream *write;
+    u_printf_pad_and_justify_stream *pad_and_justify;
+} u_printf_stream_handler;
+
+/* Used by sprintf */
+typedef struct u_localized_print_string {
+    UChar     *str;     /* Place to write the string */
+    int32_t   available;/* Number of codeunits available to write to */
+    int32_t   len;      /* Maximum number of code units that can be written to output */
+
+    ULocaleBundle  fBundle;     /* formatters */
+} u_localized_print_string;
+
+#define UP_PERCENT 0x0025
+
+/**
+ * Parse a single u_printf format string.
+ * @param fmt A pointer to a '%' character in a u_printf format specification.
+ * @param spec A pointer to a <TT>u_printf_spec</TT> to receive the parsed
+ * format specifier.
+ * @param locStringContext If present, will make sure that it will only write
+ *          to the buffer when space is available. It's done this way because
+ *          va_list sometimes can't be passed by pointer.
+ * @return The number of characters contained in this specifier.
+ */
+U_CFUNC int32_t
+u_printf_parse(const u_printf_stream_handler *streamHandler,
+               const UChar     *fmt,
+               void            *context,
+               u_localized_print_string *locStringContext,
+               ULocaleBundle   *formatBundle,
+               int32_t         *written,
+               va_list         ap);
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif


Property changes on: trunk/source/io/uprintf.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uprntf_p.c
===================================================================
--- trunk/source/io/uprntf_p.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uprntf_p.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,1374 +1,1374 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File uprntf_p.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/23/98    stephen     Creation.
-*   03/12/99    stephen     Modified for new C API.
-*   08/07/2003  george      Reunify printf implementations
-******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/ustring.h"
-
-#include "uprintf.h"
-#include "ufmt_cmn.h"
-#include "cmemory.h"
-#include "putilimp.h"
-
-/* ANSI style formatting */
-/* Use US-ASCII characters only for formatting */
-
-/* % */
-#define UFMT_SIMPLE_PERCENT {ufmt_simple_percent, u_printf_simple_percent_handler}
-/* s */
-#define UFMT_STRING         {ufmt_string, u_printf_string_handler}
-/* c */
-#define UFMT_CHAR           {ufmt_char, u_printf_char_handler}
-/* d, i */
-#define UFMT_INT            {ufmt_int, u_printf_integer_handler}
-/* u */
-#define UFMT_UINT           {ufmt_int, u_printf_uinteger_handler}
-/* o */
-#define UFMT_OCTAL          {ufmt_int, u_printf_octal_handler}
-/* x, X */
-#define UFMT_HEX            {ufmt_int, u_printf_hex_handler}
-/* f */
-#define UFMT_DOUBLE         {ufmt_double, u_printf_double_handler}
-/* e, E */
-#define UFMT_SCIENTIFIC     {ufmt_double, u_printf_scientific_handler}
-/* g, G */
-#define UFMT_SCIDBL         {ufmt_double, u_printf_scidbl_handler}
-/* n */
-#define UFMT_COUNT          {ufmt_count, u_printf_count_handler}
-
-/* non-ANSI extensions */
-/* Use US-ASCII characters only for formatting */
-
-/* p */
-#define UFMT_POINTER        {ufmt_pointer, u_printf_pointer_handler}
-/* V */
-#define UFMT_SPELLOUT       {ufmt_double, u_printf_spellout_handler}
-/* P */
-#define UFMT_PERCENT        {ufmt_double, u_printf_percent_handler}
-/* C  K is old format */
-#define UFMT_UCHAR          {ufmt_uchar, u_printf_uchar_handler}
-/* S  U is old format */
-#define UFMT_USTRING        {ufmt_ustring, u_printf_ustring_handler}
-
-
-#define UFMT_EMPTY {ufmt_empty, NULL}
-
-/**
- * A u_printf handler function.  
- * A u_printf handler is responsible for handling a single u_printf 
- * format specification, for example 'd' or 's'.
- * @param stream The UFILE to which to write output.
- * @param info A pointer to a <TT>u_printf_spec_info</TT> struct containing
- * information on the format specification.
- * @param args A pointer to the argument data
- * @return The number of Unicode characters written to <TT>stream</TT>.
- */
-typedef int32_t U_EXPORT2
-u_printf_handler(const u_printf_stream_handler  *handler,
-
-                 void                           *context,
-                 ULocaleBundle                  *formatBundle,
-                 const u_printf_spec_info       *info,
-                 const ufmt_args                *args);
-
-typedef struct u_printf_info {
-    ufmt_type_info info;
-    u_printf_handler *handler;
-} u_printf_info;
-
-/**
- * Struct encapsulating a single uprintf format specification.
- */
-typedef struct u_printf_spec {
-  u_printf_spec_info    fInfo;        /* Information on this spec */
-  int32_t        fWidthPos;     /* Position of width in arg list */
-  int32_t        fPrecisionPos;    /* Position of precision in arg list */
-  int32_t        fArgPos;    /* Position of data in arg list */
-} u_printf_spec;
-
-#define UPRINTF_NUM_FMT_HANDLERS 108
-
-/* We do not use handlers for 0-0x1f */
-#define UPRINTF_BASE_FMT_HANDLERS 0x20
-
-/* buffer size for formatting */
-#define UPRINTF_BUFFER_SIZE 1024
-#define UPRINTF_SYMBOL_BUFFER_SIZE 8
-
-static const UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
-static const UChar gSpaceStr[] = {0x20, 0}; /* " " */
-
-/* Sets the sign of a format based on u_printf_spec_info */
-/* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */
-static void
-u_printf_set_sign(UNumberFormat        *format,
-                   const u_printf_spec_info     *info,
-                   UChar *prefixBuffer,
-                   int32_t *prefixBufLen,
-                   UErrorCode *status)
-{
-    if(info->fShowSign) {
-        *prefixBufLen = unum_getTextAttribute(format,
-                                              UNUM_POSITIVE_PREFIX,
-                                              prefixBuffer,
-                                              *prefixBufLen,
-                                              status);
-        if (info->fSpace) {
-            /* Setting UNUM_PLUS_SIGN_SYMBOL affects the exponent too. */
-            /* unum_setSymbol(format, UNUM_PLUS_SIGN_SYMBOL, gSpaceStr, 1, &status); */
-            unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status);
-        }
-        else {
-            UChar plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE];
-            int32_t symbolLen;
-
-            symbolLen = unum_getSymbol(format,
-                UNUM_PLUS_SIGN_SYMBOL,
-                plusSymbol,
-                sizeof(plusSymbol)/sizeof(*plusSymbol),
-                status);
-            unum_setTextAttribute(format,
-                UNUM_POSITIVE_PREFIX,
-                plusSymbol,
-                symbolLen,
-                status);
-        }
-    }
-    else {
-        *prefixBufLen = 0;
-    }
-}
-
-static void
-u_printf_reset_sign(UNumberFormat        *format,
-                   const u_printf_spec_info     *info,
-                   UChar *prefixBuffer,
-                   int32_t *prefixBufLen,
-                   UErrorCode *status)
-{
-    if(info->fShowSign) {
-        unum_setTextAttribute(format,
-                              UNUM_POSITIVE_PREFIX,
-                              prefixBuffer,
-                              *prefixBufLen,
-                              status);
-    }
-}
-
-
-/* handle a '%' */
-static int32_t
-u_printf_simple_percent_handler(const u_printf_stream_handler  *handler,
-                                void                           *context,
-                                ULocaleBundle                  *formatBundle,
-                                const u_printf_spec_info       *info,
-                                const ufmt_args                *args)
-{
-    static const UChar PERCENT[] = { UP_PERCENT };
-
-    /* put a single '%' onto the output */
-    return handler->write(context, PERCENT, 1);
-}
-
-/* handle 's' */
-static int32_t
-u_printf_string_handler(const u_printf_stream_handler  *handler,
-                        void                           *context,
-                        ULocaleBundle                  *formatBundle,
-                        const u_printf_spec_info       *info,
-                        const ufmt_args                *args)
-{
-    UChar *s;
-    UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
-    int32_t len, written;
-    int32_t argSize;
-    const char *arg = (const char*)(args[0].ptrValue);
-
-    /* convert from the default codepage to Unicode */
-    if (arg) {
-        argSize = (int32_t)strlen(arg) + 1;
-        if (argSize >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
-            s = ufmt_defaultCPToUnicode(arg, argSize,
-                    (UChar *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)),
-                    MAX_UCHAR_BUFFER_NEEDED(argSize));
-            if(s == NULL) {
-                return 0;
-            }
-        }
-        else {
-            s = ufmt_defaultCPToUnicode(arg, argSize, buffer,
-                    sizeof(buffer)/sizeof(UChar));
-        }
-    }
-    else {
-        s = (UChar *)gNullStr;
-    }
-    len = u_strlen(s);
-
-    /* width = minimum # of characters to write */
-    /* precision = maximum # of characters to write */
-    if (info->fPrecision != -1 && info->fPrecision < len) {
-        len = info->fPrecision;
-    }
-
-    written = handler->pad_and_justify(context, info, s, len);
-
-    /* clean up */
-    if (gNullStr != s && buffer != s) {
-        uprv_free(s);
-    }
-
-    return written;
-}
-
-static int32_t
-u_printf_char_handler(const u_printf_stream_handler  *handler,
-                      void                           *context,
-                      ULocaleBundle                  *formatBundle,
-                      const u_printf_spec_info       *info,
-                      const ufmt_args                *args)
-{
-    UChar s[UTF_MAX_CHAR_LENGTH+1];
-    int32_t len = 1, written;
-    unsigned char arg = (unsigned char)(args[0].int64Value);
-
-    /* convert from default codepage to Unicode */
-    ufmt_defaultCPToUnicode((const char *)&arg, 2, s, sizeof(s)/sizeof(UChar));
-
-    /* Remember that this may be an MBCS character */
-    if (arg != 0) {
-        len = u_strlen(s);
-    }
-
-    /* width = minimum # of characters to write */
-    /* precision = maximum # of characters to write */
-    /* precision is ignored when handling a char */
-
-    written = handler->pad_and_justify(context, info, s, len);
-
-    return written;
-}
-
-static int32_t
-u_printf_double_handler(const u_printf_stream_handler  *handler,
-                        void                           *context,
-                        ULocaleBundle                  *formatBundle,
-                        const u_printf_spec_info       *info,
-                        const ufmt_args                *args)
-{
-    double        num         = (double) (args[0].doubleValue);
-    UNumberFormat  *format;
-    UChar          result[UPRINTF_BUFFER_SIZE];
-    UChar          prefixBuffer[UPRINTF_BUFFER_SIZE];
-    int32_t        prefixBufferLen = sizeof(prefixBuffer);
-    int32_t        minDecimalDigits;
-    int32_t        maxDecimalDigits;
-    int32_t        resultLen;
-    UErrorCode     status        = U_ZERO_ERROR;
-
-    prefixBuffer[0] = 0;
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLongDouble)
-    num &= DBL_MAX;*/
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* save the formatter's state */
-    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
-    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
-
-    /* set the appropriate flags and number of decimal digits on the formatter */
-    if(info->fPrecision != -1) {
-        /* set the # of decimal digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
-    }
-    else if(info->fAlt) {
-        /* '#' means always show decimal point */
-        /* copy of printf behavior on Solaris - '#' shows 6 digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-    else {
-        /* # of decimal digits is 6 if precision not specified regardless of locale */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-
-    /* set whether to show the sign */
-    if (info->fShowSign) {
-        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
-    }
-
-    /* format the number */
-    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    /* TODO: Is this needed? */
-    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
-    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
-
-    if (info->fShowSign) {
-        /* Reset back to original value regardless of what the error was */
-        UErrorCode localStatus = U_ZERO_ERROR;
-        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-/* HSYS */
-static int32_t
-u_printf_integer_handler(const u_printf_stream_handler  *handler,
-                         void                           *context,
-                         ULocaleBundle                  *formatBundle,
-                         const u_printf_spec_info       *info,
-                         const ufmt_args                *args)
-{
-    int64_t         num        = args[0].int64Value;
-    UNumberFormat   *format;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
-    int32_t         prefixBufferLen = sizeof(prefixBuffer);
-    int32_t         minDigits     = -1;
-    int32_t         resultLen;
-    UErrorCode      status        = U_ZERO_ERROR;
-
-    prefixBuffer[0] = 0;
-
-    /* mask off any necessary bits */
-    if (info->fIsShort)
-        num = (int16_t)num;
-    else if (!info->fIsLongLong)
-        num = (int32_t)num;
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* set the appropriate flags on the formatter */
-
-    /* set the minimum integer digits */
-    if(info->fPrecision != -1) {
-        /* set the minimum # of digits */
-        minDigits = unum_getAttribute(format, UNUM_MIN_INTEGER_DIGITS);
-        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, info->fPrecision);
-    }
-
-    /* set whether to show the sign */
-    if(info->fShowSign) {
-        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
-    }
-
-    /* format the number */
-    resultLen = unum_formatInt64(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    if (minDigits != -1) {
-        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, minDigits);
-    }
-
-    if (info->fShowSign) {
-        /* Reset back to original value regardless of what the error was */
-        UErrorCode localStatus = U_ZERO_ERROR;
-        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-static int32_t
-u_printf_hex_handler(const u_printf_stream_handler  *handler,
-                     void                           *context,
-                     ULocaleBundle                  *formatBundle,
-                     const u_printf_spec_info       *info,
-                     const ufmt_args                *args)
-{
-    int64_t         num        = args[0].int64Value;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    int32_t         len        = UPRINTF_BUFFER_SIZE;
-
-
-    /* mask off any necessary bits */
-    if (info->fIsShort)
-        num &= UINT16_MAX;
-    else if (!info->fIsLongLong)
-        num &= UINT32_MAX;
-
-    /* format the number, preserving the minimum # of digits */
-    ufmt_64tou(result, &len, num, 16,
-        (UBool)(info->fSpec == 0x0078),
-        (info->fPrecision == -1 && info->fZero) ? info->fWidth : info->fPrecision);
-
-    /* convert to alt form, if desired */
-    if(num != 0 && info->fAlt && len < UPRINTF_BUFFER_SIZE - 2) {
-        /* shift the formatted string right by 2 chars */
-        memmove(result + 2, result, len * sizeof(UChar));
-        result[0] = 0x0030;
-        result[1] = info->fSpec;
-        len += 2;
-    }
-
-    return handler->pad_and_justify(context, info, result, len);
-}
-
-static int32_t
-u_printf_octal_handler(const u_printf_stream_handler  *handler,
-                       void                           *context,
-                       ULocaleBundle                  *formatBundle,
-                       const u_printf_spec_info       *info,
-                       const ufmt_args                *args)
-{
-    int64_t         num        = args[0].int64Value;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    int32_t         len        = UPRINTF_BUFFER_SIZE;
-
-
-    /* mask off any necessary bits */
-    if (info->fIsShort)
-        num &= UINT16_MAX;
-    else if (!info->fIsLongLong)
-        num &= UINT32_MAX;
-
-    /* format the number, preserving the minimum # of digits */
-    ufmt_64tou(result, &len, num, 8,
-        FALSE, /* doesn't matter for octal */
-        info->fPrecision == -1 && info->fZero ? info->fWidth : info->fPrecision);
-
-    /* convert to alt form, if desired */
-    if(info->fAlt && result[0] != 0x0030 && len < UPRINTF_BUFFER_SIZE - 1) {
-        /* shift the formatted string right by 1 char */
-        memmove(result + 1, result, len * sizeof(UChar));
-        result[0] = 0x0030;
-        len += 1;
-    }
-
-    return handler->pad_and_justify(context, info, result, len);
-}
-
-static int32_t
-u_printf_uinteger_handler(const u_printf_stream_handler *handler,
-                          void                          *context,
-                          ULocaleBundle                 *formatBundle,
-                          const u_printf_spec_info      *info,
-                          const ufmt_args               *args)
-{
-    int64_t         num        = args[0].int64Value;
-    UNumberFormat   *format;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    int32_t         minDigits     = -1;
-    int32_t         resultLen;
-    UErrorCode      status        = U_ZERO_ERROR;
-
-    /* TODO: Fix this once uint64_t can be formatted. */
-    if (info->fIsShort)
-        num &= UINT16_MAX;
-    else if (!info->fIsLongLong)
-        num &= UINT32_MAX;
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* set the appropriate flags on the formatter */
-
-    /* set the minimum integer digits */
-    if(info->fPrecision != -1) {
-        /* set the minimum # of digits */
-        minDigits = unum_getAttribute(format, UNUM_MIN_INTEGER_DIGITS);
-        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, info->fPrecision);
-    }
-
-    /* To mirror other stdio implementations, we ignore the sign argument */
-
-    /* format the number */
-    resultLen = unum_formatInt64(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    if (minDigits != -1) {
-        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, minDigits);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-static int32_t
-u_printf_pointer_handler(const u_printf_stream_handler  *handler,
-                         void                           *context,
-                         ULocaleBundle                  *formatBundle,
-                         const u_printf_spec_info       *info,
-                         const ufmt_args                *args)
-{
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    int32_t         len  = UPRINTF_BUFFER_SIZE;
-
-    /* format the pointer in hex */
-    ufmt_ptou(result, &len, args[0].ptrValue, TRUE/*, info->fPrecision*/);
-
-    return handler->pad_and_justify(context, info, result, len);
-}
-
-static int32_t
-u_printf_scientific_handler(const u_printf_stream_handler  *handler,
-                            void                           *context,
-                            ULocaleBundle                  *formatBundle,
-                            const u_printf_spec_info       *info,
-                            const ufmt_args                *args)
-{
-    double          num         = (double) (args[0].doubleValue);
-    UNumberFormat   *format;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
-    int32_t         prefixBufferLen = sizeof(prefixBuffer);
-    int32_t         minDecimalDigits;
-    int32_t         maxDecimalDigits;
-    UErrorCode      status        = U_ZERO_ERROR;
-    UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
-    int32_t srcLen, expLen;
-    int32_t resultLen;
-    UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
-
-    prefixBuffer[0] = 0;
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLongDouble)
-    num &= DBL_MAX;*/
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_SCIENTIFIC);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* set the appropriate flags on the formatter */
-
-    srcLen = unum_getSymbol(format,
-        UNUM_EXPONENTIAL_SYMBOL,
-        srcExpBuf,
-        sizeof(srcExpBuf),
-        &status);
-
-    /* Upper/lower case the e */
-    if (info->fSpec == (UChar)0x65 /* e */) {
-        expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf),
-            srcExpBuf, srcLen,
-            formatBundle->fLocale,
-            &status);
-    }
-    else {
-        expLen = u_strToUpper(expBuf, (int32_t)sizeof(expBuf),
-            srcExpBuf, srcLen,
-            formatBundle->fLocale,
-            &status);
-    }
-
-    unum_setSymbol(format,
-        UNUM_EXPONENTIAL_SYMBOL,
-        expBuf,
-        expLen,
-        &status);
-
-    /* save the formatter's state */
-    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
-    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
-
-    /* set the appropriate flags and number of decimal digits on the formatter */
-    if(info->fPrecision != -1) {
-        /* set the # of decimal digits */
-        if (info->fOrigSpec == (UChar)0x65 /* e */ || info->fOrigSpec == (UChar)0x45 /* E */) {
-            unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
-        }
-        else {
-            unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, 1);
-            unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, info->fPrecision);
-        }
-    }
-    else if(info->fAlt) {
-        /* '#' means always show decimal point */
-        /* copy of printf behavior on Solaris - '#' shows 6 digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-    else {
-        /* # of decimal digits is 6 if precision not specified */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-
-    /* set whether to show the sign */
-    if (info->fShowSign) {
-        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
-    }
-
-    /* format the number */
-    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    /* TODO: Is this needed? */
-    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
-    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
-
-    /* Since we're the only one using the scientific
-       format, we don't need to save the old exponent value. */
-    /*unum_setSymbol(format,
-        UNUM_EXPONENTIAL_SYMBOL,
-        srcExpBuf,
-        srcLen,
-        &status);*/
-
-    if (info->fShowSign) {
-        /* Reset back to original value regardless of what the error was */
-        UErrorCode localStatus = U_ZERO_ERROR;
-        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-static int32_t
-u_printf_percent_handler(const u_printf_stream_handler  *handler,
-                         void                           *context,
-                         ULocaleBundle                  *formatBundle,
-                         const u_printf_spec_info       *info,
-                         const ufmt_args                *args)
-{
-    double          num         = (double) (args[0].doubleValue);
-    UNumberFormat   *format;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
-    int32_t         prefixBufferLen = sizeof(prefixBuffer);
-    int32_t         minDecimalDigits;
-    int32_t         maxDecimalDigits;
-    int32_t         resultLen;
-    UErrorCode      status        = U_ZERO_ERROR;
-
-    prefixBuffer[0] = 0;
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLongDouble)
-    num &= DBL_MAX;*/
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_PERCENT);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* save the formatter's state */
-    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
-    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
-
-    /* set the appropriate flags and number of decimal digits on the formatter */
-    if(info->fPrecision != -1) {
-        /* set the # of decimal digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
-    }
-    else if(info->fAlt) {
-        /* '#' means always show decimal point */
-        /* copy of printf behavior on Solaris - '#' shows 6 digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-    else {
-        /* # of decimal digits is 6 if precision not specified */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-
-    /* set whether to show the sign */
-    if (info->fShowSign) {
-        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
-    }
-
-    /* format the number */
-    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    /* TODO: Is this needed? */
-    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
-    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
-
-    if (info->fShowSign) {
-        /* Reset back to original value regardless of what the error was */
-        UErrorCode localStatus = U_ZERO_ERROR;
-        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-static int32_t
-u_printf_ustring_handler(const u_printf_stream_handler  *handler,
-                         void                           *context,
-                         ULocaleBundle                  *formatBundle,
-                         const u_printf_spec_info       *info,
-                         const ufmt_args                *args)
-{
-    int32_t len, written;
-    const UChar *arg = (const UChar*)(args[0].ptrValue);
-
-    /* allocate enough space for the buffer */
-    if (arg == NULL) {
-        arg = gNullStr;
-    }
-    len = u_strlen(arg);
-
-    /* width = minimum # of characters to write */
-    /* precision = maximum # of characters to write */
-    if (info->fPrecision != -1 && info->fPrecision < len) {
-        len = info->fPrecision;
-    }
-
-    /* determine if the string should be padded */
-    written = handler->pad_and_justify(context, info, arg, len);
-
-    return written;
-}
-
-static int32_t
-u_printf_uchar_handler(const u_printf_stream_handler  *handler,
-                       void                           *context,
-                       ULocaleBundle                  *formatBundle,
-                       const u_printf_spec_info       *info,
-                       const ufmt_args                *args)
-{
-    int32_t written = 0;
-    UChar arg = (UChar)(args[0].int64Value);
-
-    /* width = minimum # of characters to write */
-    /* precision = maximum # of characters to write */
-    /* precision is ignored when handling a uchar */
-
-    /* determine if the string should be padded */
-    written = handler->pad_and_justify(context, info, &arg, 1);
-
-    return written;
-}
-
-static int32_t
-u_printf_scidbl_handler(const u_printf_stream_handler  *handler,
-                        void                           *context,
-                        ULocaleBundle                  *formatBundle,
-                        const u_printf_spec_info       *info,
-                        const ufmt_args                *args)
-{
-    u_printf_spec_info scidbl_info;
-    double      num = args[0].doubleValue;
-    int32_t     retVal;
-
-    memcpy(&scidbl_info, info, sizeof(u_printf_spec_info));
-
-    /* determine whether to use 'd', 'e' or 'f' notation */
-    if (scidbl_info.fPrecision == -1 && num == uprv_trunc(num))
-    {
-        /* use 'f' notation */
-        scidbl_info.fSpec = 0x0066;
-        scidbl_info.fPrecision = 0;
-        /* call the double handler */
-        retVal = u_printf_double_handler(handler, context, formatBundle, &scidbl_info, args);
-    }
-    else if(num < 0.0001 || (scidbl_info.fPrecision < 1 && 1000000.0 <= num)
-        || (scidbl_info.fPrecision != -1 && num > uprv_pow10(scidbl_info.fPrecision)))
-    {
-        /* use 'e' or 'E' notation */
-        scidbl_info.fSpec = scidbl_info.fSpec - 2;
-        if (scidbl_info.fPrecision == -1) {
-            scidbl_info.fPrecision = 5;
-        }
-        /* call the scientific handler */
-        retVal = u_printf_scientific_handler(handler, context, formatBundle, &scidbl_info, args);
-    }
-    else {
-        UNumberFormat   *format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
-        int32_t maxSigDecimalDigits = unum_getAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS);
-        int32_t significantDigits = scidbl_info.fPrecision;
-
-        /* use 'f' notation */
-        scidbl_info.fSpec = 0x0066;
-        if (significantDigits == -1) {
-            significantDigits = 6;
-        }
-        unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, TRUE);
-        unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, significantDigits);
-        /* call the double handler */
-        retVal = u_printf_double_handler(handler, context, formatBundle, &scidbl_info, args);
-        unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, maxSigDecimalDigits);
-        unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, FALSE);
-    }
-    return retVal;
-}
-
-static int32_t
-u_printf_count_handler(const u_printf_stream_handler  *handler,
-                       void                           *context,
-                       ULocaleBundle                  *formatBundle,
-                       const u_printf_spec_info       *info,
-                       const ufmt_args                *args)
-{
-    int32_t *count = (int32_t*)(args[0].ptrValue);
-
-    /* in the special case of count, the u_printf_spec_info's width */
-    /* will contain the # of chars written thus far */
-    *count = info->fWidth;
-
-    return 0;
-}
-
-static int32_t
-u_printf_spellout_handler(const u_printf_stream_handler *handler,
-                          void                          *context,
-                          ULocaleBundle                 *formatBundle,
-                          const u_printf_spec_info      *info,
-                          const ufmt_args               *args)
-{
-    double          num         = (double) (args[0].doubleValue);
-    UNumberFormat   *format;
-    UChar           result[UPRINTF_BUFFER_SIZE];
-    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
-    int32_t         prefixBufferLen = sizeof(prefixBuffer);
-    int32_t         minDecimalDigits;
-    int32_t         maxDecimalDigits;
-    int32_t         resultLen;
-    UErrorCode      status        = U_ZERO_ERROR;
-
-    prefixBuffer[0] = 0;
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLongDouble)
-    num &= DBL_MAX;*/
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(formatBundle, UNUM_SPELLOUT);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* save the formatter's state */
-    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
-    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
-
-    /* set the appropriate flags and number of decimal digits on the formatter */
-    if(info->fPrecision != -1) {
-        /* set the # of decimal digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
-    }
-    else if(info->fAlt) {
-        /* '#' means always show decimal point */
-        /* copy of printf behavior on Solaris - '#' shows 6 digits */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-    else {
-        /* # of decimal digits is 6 if precision not specified */
-        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
-    }
-
-    /* set whether to show the sign */
-    if (info->fShowSign) {
-        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
-    }
-
-    /* format the number */
-    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
-
-    if (U_FAILURE(status)) {
-        resultLen = 0;
-    }
-
-    /* restore the number format */
-    /* TODO: Is this needed? */
-    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
-    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
-
-    if (info->fShowSign) {
-        /* Reset back to original value regardless of what the error was */
-        UErrorCode localStatus = U_ZERO_ERROR;
-        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
-    }
-
-    return handler->pad_and_justify(context, info, result, resultLen);
-}
-
-/* Use US-ASCII characters only for formatting. Most codepages have
- characters 20-7F from Unicode. Using any other codepage specific
- characters will make it very difficult to format the string on
- non-Unicode machines */
-static const u_printf_info g_u_printf_infos[UPRINTF_NUM_FMT_HANDLERS] = {
-/* 0x20 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_SIMPLE_PERCENT,UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x30 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x40 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR,
-    UFMT_EMPTY,         UFMT_SCIENTIFIC,    UFMT_EMPTY,         UFMT_SCIDBL,
-#ifdef U_USE_OBSOLETE_IO_FORMATTING
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR/*deprecated*/,
-#else
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-#endif
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x50 */
-    UFMT_PERCENT,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_USTRING,
-#ifdef U_USE_OBSOLETE_IO_FORMATTING
-    UFMT_EMPTY,         UFMT_USTRING/*deprecated*/,UFMT_SPELLOUT,      UFMT_EMPTY,
-#else
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SPELLOUT,      UFMT_EMPTY,
-#endif
-    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x60 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_CHAR,
-    UFMT_INT,           UFMT_SCIENTIFIC,    UFMT_DOUBLE,        UFMT_SCIDBL,
-    UFMT_EMPTY,         UFMT_INT,           UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_COUNT,         UFMT_OCTAL,
-
-/* 0x70 */
-    UFMT_POINTER,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_STRING,
-    UFMT_EMPTY,         UFMT_UINT,          UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-};
-
-/* flag characters for uprintf */
-#define FLAG_MINUS 0x002D
-#define FLAG_PLUS 0x002B
-#define FLAG_SPACE 0x0020
-#define FLAG_POUND 0x0023
-#define FLAG_ZERO  0x0030
-#define FLAG_PAREN 0x0028
-
-#define ISFLAG(s)    (s) == FLAG_MINUS || \
-            (s) == FLAG_PLUS || \
-            (s) == FLAG_SPACE || \
-            (s) == FLAG_POUND || \
-            (s) == FLAG_ZERO || \
-            (s) == FLAG_PAREN
-
-/* special characters for uprintf */
-#define SPEC_ASTERISK 0x002A
-#define SPEC_DOLLARSIGN 0x0024
-#define SPEC_PERIOD 0x002E
-#define SPEC_PERCENT 0x0025
-
-/* unicode digits */
-#define DIGIT_ZERO 0x0030
-#define DIGIT_ONE 0x0031
-#define DIGIT_TWO 0x0032
-#define DIGIT_THREE 0x0033
-#define DIGIT_FOUR 0x0034
-#define DIGIT_FIVE 0x0035
-#define DIGIT_SIX 0x0036
-#define DIGIT_SEVEN 0x0037
-#define DIGIT_EIGHT 0x0038
-#define DIGIT_NINE 0x0039
-
-#define ISDIGIT(s)    (s) == DIGIT_ZERO || \
-            (s) == DIGIT_ONE || \
-            (s) == DIGIT_TWO || \
-            (s) == DIGIT_THREE || \
-            (s) == DIGIT_FOUR || \
-            (s) == DIGIT_FIVE || \
-            (s) == DIGIT_SIX || \
-            (s) == DIGIT_SEVEN || \
-            (s) == DIGIT_EIGHT || \
-            (s) == DIGIT_NINE
-
-/* u_printf modifiers */
-#define MOD_H 0x0068
-#define MOD_LOWERL 0x006C
-#define MOD_L 0x004C
-
-#define ISMOD(s)    (s) == MOD_H || \
-            (s) == MOD_LOWERL || \
-            (s) == MOD_L
-
-/* We parse the argument list in Unicode */
-U_CFUNC int32_t
-u_printf_parse(const u_printf_stream_handler *streamHandler,
-               const UChar     *fmt,
-               void            *context,
-               u_localized_print_string *locStringContext,
-               ULocaleBundle   *formatBundle,
-               int32_t         *written,
-               va_list         ap)
-{
-    uint16_t         handlerNum;
-    ufmt_args        args;
-    ufmt_type_info   argType;
-    u_printf_handler *handler;
-    u_printf_spec    spec;
-    u_printf_spec_info *info = &(spec.fInfo);
-
-    const UChar *alias = fmt;
-    const UChar *backup;
-    const UChar *lastAlias;
-
-    /* iterate through the pattern */
-    while(!locStringContext || locStringContext->available > 0) {
-
-        /* find the next '%' */
-        lastAlias = alias;
-        while(*alias != UP_PERCENT && *alias != 0x0000) {
-            alias++;
-        }
-
-        /* write any characters before the '%' */
-        if(alias > lastAlias) {
-            *written += (streamHandler->write)(context, lastAlias, (int32_t)(alias - lastAlias));
-        }
-
-        /* break if at end of string */
-        if(*alias == 0x0000) {
-            break;
-        }
-
-        /* initialize spec to default values */
-        spec.fWidthPos     = -1;
-        spec.fPrecisionPos = -1;
-        spec.fArgPos       = -1;
-
-        uprv_memset(info, 0, sizeof(*info));
-        info->fPrecision    = -1;
-        info->fWidth        = -1;
-        info->fPadChar      = 0x0020;
-
-        /* skip over the initial '%' */
-        alias++;
-
-        /* Check for positional argument */
-        if(ISDIGIT(*alias)) {
-
-            /* Save the current position */
-            backup = alias;
-
-            /* handle positional parameters */
-            if(ISDIGIT(*alias)) {
-                spec.fArgPos = (int) (*alias++ - DIGIT_ZERO);
-
-                while(ISDIGIT(*alias)) {
-                    spec.fArgPos *= 10;
-                    spec.fArgPos += (int) (*alias++ - DIGIT_ZERO);
-                }
-            }
-
-            /* if there is no '$', don't read anything */
-            if(*alias != SPEC_DOLLARSIGN) {
-                spec.fArgPos = -1;
-                alias = backup;
-            }
-            /* munge the '$' */
-            else
-                alias++;
-        }
-
-        /* Get any format flags */
-        while(ISFLAG(*alias)) {
-            switch(*alias++) {
-
-                /* left justify */
-            case FLAG_MINUS:
-                info->fLeft = TRUE;
-                break;
-
-                /* always show sign */
-            case FLAG_PLUS:
-                info->fShowSign = TRUE;
-                break;
-
-                /* use space if no sign present */
-            case FLAG_SPACE:
-                info->fShowSign = TRUE;
-                info->fSpace = TRUE;
-                break;
-
-                /* use alternate form */
-            case FLAG_POUND:
-                info->fAlt = TRUE;
-                break;
-
-                /* pad with leading zeroes */
-            case FLAG_ZERO:
-                info->fZero = TRUE;
-                info->fPadChar = 0x0030;
-                break;
-
-                /* pad character specified */
-            case FLAG_PAREN:
-
-                /* TODO test that all four are numbers */
-                /* first four characters are hex values for pad char */
-                info->fPadChar = (UChar)ufmt_digitvalue(*alias++);
-                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
-                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
-                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
-
-                /* final character is ignored */
-                alias++;
-
-                break;
-            }
-        }
-
-        /* Get the width */
-
-        /* width is specified out of line */
-        if(*alias == SPEC_ASTERISK) {
-
-            info->fWidth = -2;
-
-            /* Skip the '*' */
-            alias++;
-
-            /* Save the current position */
-            backup = alias;
-
-            /* handle positional parameters */
-            if(ISDIGIT(*alias)) {
-                spec.fWidthPos = (int) (*alias++ - DIGIT_ZERO);
-
-                while(ISDIGIT(*alias)) {
-                    spec.fWidthPos *= 10;
-                    spec.fWidthPos += (int) (*alias++ - DIGIT_ZERO);
-                }
-            }
-
-            /* if there is no '$', don't read anything */
-            if(*alias != SPEC_DOLLARSIGN) {
-                spec.fWidthPos = -1;
-                alias = backup;
-            }
-            /* munge the '$' */
-            else
-                alias++;
-        }
-        /* read the width, if present */
-        else if(ISDIGIT(*alias)){
-            info->fWidth = (int) (*alias++ - DIGIT_ZERO);
-
-            while(ISDIGIT(*alias)) {
-                info->fWidth *= 10;
-                info->fWidth += (int) (*alias++ - DIGIT_ZERO);
-            }
-        }
-
-        /* Get the precision */
-
-        if(*alias == SPEC_PERIOD) {
-
-            /* eat up the '.' */
-            alias++;
-
-            /* precision is specified out of line */
-            if(*alias == SPEC_ASTERISK) {
-
-                info->fPrecision = -2;
-
-                /* Skip the '*' */
-                alias++;
-
-                /* save the current position */
-                backup = alias;
-
-                /* handle positional parameters */
-                if(ISDIGIT(*alias)) {
-                    spec.fPrecisionPos = (int) (*alias++ - DIGIT_ZERO);
-
-                    while(ISDIGIT(*alias)) {
-                        spec.fPrecisionPos *= 10;
-                        spec.fPrecisionPos += (int) (*alias++ - DIGIT_ZERO);
-                    }
-
-                    /* if there is no '$', don't read anything */
-                    if(*alias != SPEC_DOLLARSIGN) {
-                        spec.fPrecisionPos = -1;
-                        alias = backup;
-                    }
-                    else {
-                        /* munge the '$' */
-                        alias++;
-                    }
-                }
-            }
-            /* read the precision */
-            else if(ISDIGIT(*alias)){
-                info->fPrecision = (int) (*alias++ - DIGIT_ZERO);
-
-                while(ISDIGIT(*alias)) {
-                    info->fPrecision *= 10;
-                    info->fPrecision += (int) (*alias++ - DIGIT_ZERO);
-                }
-            }
-        }
-
-        /* Get any modifiers */
-        if(ISMOD(*alias)) {
-            switch(*alias++) {
-
-                /* short */
-            case MOD_H:
-                info->fIsShort = TRUE;
-                break;
-
-                /* long or long long */
-            case MOD_LOWERL:
-                if(*alias == MOD_LOWERL) {
-                    info->fIsLongLong = TRUE;
-                    /* skip over the next 'l' */
-                    alias++;
-                }
-                else
-                    info->fIsLong = TRUE;
-                break;
-
-                /* long double */
-            case MOD_L:
-                info->fIsLongDouble = TRUE;
-                break;
-            }
-        }
-
-        /* finally, get the specifier letter */
-        info->fSpec = *alias++;
-        info->fOrigSpec = info->fSpec;
-
-        /* fill in the precision and width, if specified out of line */
-
-        /* width specified out of line */
-        if(spec.fInfo.fWidth == -2) {
-            if(spec.fWidthPos == -1) {
-                /* read the width from the argument list */
-                info->fWidth = va_arg(ap, int32_t);
-            }
-            /* else handle positional parameter */
-
-            /* if it's negative, take the absolute value and set left alignment */
-            if(info->fWidth < 0) {
-                info->fWidth *= -1; /* Make positive */
-                info->fLeft = TRUE;
-            }
-        }
-
-        /* precision specified out of line */
-        if(info->fPrecision == -2) {
-            if(spec.fPrecisionPos == -1) {
-                /* read the precision from the argument list */
-                info->fPrecision = va_arg(ap, int32_t);
-            }
-            /* else handle positional parameter */
-
-            /* if it's negative, set it to zero */
-            if(info->fPrecision < 0)
-                info->fPrecision = 0;
-        }
-
-        handlerNum = (uint16_t)(info->fSpec - UPRINTF_BASE_FMT_HANDLERS);
-        if (handlerNum < UPRINTF_NUM_FMT_HANDLERS) {
-            /* query the info function for argument information */
-            argType = g_u_printf_infos[ handlerNum ].info;
-            switch(argType) {
-            case ufmt_count:
-                /* set the spec's width to the # of chars written */
-                info->fWidth = *written;
-                /* fall through to set the pointer */
-            case ufmt_string:
-            case ufmt_ustring:
-            case ufmt_pointer:
-                args.ptrValue = va_arg(ap, void*);
-                break;
-            case ufmt_char:
-            case ufmt_uchar:
-            case ufmt_int:
-                if (info->fIsLongLong) {
-                    args.int64Value = va_arg(ap, int64_t);
-                }
-                else {
-                    args.int64Value = va_arg(ap, int32_t);
-                }
-                break;
-            case ufmt_float:
-                args.floatValue = (float) va_arg(ap, double);
-                break;
-            case ufmt_double:
-                args.doubleValue = va_arg(ap, double);
-                break;
-            default:
-                /* else args is ignored */
-                args.ptrValue = NULL;
-                break;
-            }
-
-            /* call the handler function */
-            handler = g_u_printf_infos[ handlerNum ].handler;
-            if(handler != 0) {
-                *written += (*handler)(streamHandler, context, formatBundle, info, &args);
-            }
-            else {
-                /* just echo unknown tags */
-                *written += (streamHandler->write)(context, fmt, (int32_t)(alias - lastAlias));
-            }
-        }
-        else {
-            /* just echo unknown tags */
-            *written += (streamHandler->write)(context, fmt, (int32_t)(alias - lastAlias));
-        }
-    }
-    /* return # of characters in this format that have been parsed. */
-    return (int32_t)(alias - fmt);
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File uprntf_p.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/23/98    stephen     Creation.
+*   03/12/99    stephen     Modified for new C API.
+*   08/07/2003  george      Reunify printf implementations
+******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ustring.h"
+
+#include "uprintf.h"
+#include "ufmt_cmn.h"
+#include "cmemory.h"
+#include "putilimp.h"
+
+/* ANSI style formatting */
+/* Use US-ASCII characters only for formatting */
+
+/* % */
+#define UFMT_SIMPLE_PERCENT {ufmt_simple_percent, u_printf_simple_percent_handler}
+/* s */
+#define UFMT_STRING         {ufmt_string, u_printf_string_handler}
+/* c */
+#define UFMT_CHAR           {ufmt_char, u_printf_char_handler}
+/* d, i */
+#define UFMT_INT            {ufmt_int, u_printf_integer_handler}
+/* u */
+#define UFMT_UINT           {ufmt_int, u_printf_uinteger_handler}
+/* o */
+#define UFMT_OCTAL          {ufmt_int, u_printf_octal_handler}
+/* x, X */
+#define UFMT_HEX            {ufmt_int, u_printf_hex_handler}
+/* f */
+#define UFMT_DOUBLE         {ufmt_double, u_printf_double_handler}
+/* e, E */
+#define UFMT_SCIENTIFIC     {ufmt_double, u_printf_scientific_handler}
+/* g, G */
+#define UFMT_SCIDBL         {ufmt_double, u_printf_scidbl_handler}
+/* n */
+#define UFMT_COUNT          {ufmt_count, u_printf_count_handler}
+
+/* non-ANSI extensions */
+/* Use US-ASCII characters only for formatting */
+
+/* p */
+#define UFMT_POINTER        {ufmt_pointer, u_printf_pointer_handler}
+/* V */
+#define UFMT_SPELLOUT       {ufmt_double, u_printf_spellout_handler}
+/* P */
+#define UFMT_PERCENT        {ufmt_double, u_printf_percent_handler}
+/* C  K is old format */
+#define UFMT_UCHAR          {ufmt_uchar, u_printf_uchar_handler}
+/* S  U is old format */
+#define UFMT_USTRING        {ufmt_ustring, u_printf_ustring_handler}
+
+
+#define UFMT_EMPTY {ufmt_empty, NULL}
+
+/**
+ * A u_printf handler function.  
+ * A u_printf handler is responsible for handling a single u_printf 
+ * format specification, for example 'd' or 's'.
+ * @param stream The UFILE to which to write output.
+ * @param info A pointer to a <TT>u_printf_spec_info</TT> struct containing
+ * information on the format specification.
+ * @param args A pointer to the argument data
+ * @return The number of Unicode characters written to <TT>stream</TT>.
+ */
+typedef int32_t U_EXPORT2
+u_printf_handler(const u_printf_stream_handler  *handler,
+
+                 void                           *context,
+                 ULocaleBundle                  *formatBundle,
+                 const u_printf_spec_info       *info,
+                 const ufmt_args                *args);
+
+typedef struct u_printf_info {
+    ufmt_type_info info;
+    u_printf_handler *handler;
+} u_printf_info;
+
+/**
+ * Struct encapsulating a single uprintf format specification.
+ */
+typedef struct u_printf_spec {
+  u_printf_spec_info    fInfo;        /* Information on this spec */
+  int32_t        fWidthPos;     /* Position of width in arg list */
+  int32_t        fPrecisionPos;    /* Position of precision in arg list */
+  int32_t        fArgPos;    /* Position of data in arg list */
+} u_printf_spec;
+
+#define UPRINTF_NUM_FMT_HANDLERS 108
+
+/* We do not use handlers for 0-0x1f */
+#define UPRINTF_BASE_FMT_HANDLERS 0x20
+
+/* buffer size for formatting */
+#define UPRINTF_BUFFER_SIZE 1024
+#define UPRINTF_SYMBOL_BUFFER_SIZE 8
+
+static const UChar gNullStr[] = {0x28, 0x6E, 0x75, 0x6C, 0x6C, 0x29, 0}; /* "(null)" */
+static const UChar gSpaceStr[] = {0x20, 0}; /* " " */
+
+/* Sets the sign of a format based on u_printf_spec_info */
+/* TODO: Is setting the prefix symbol to a positive sign a good idea in all locales? */
+static void
+u_printf_set_sign(UNumberFormat        *format,
+                   const u_printf_spec_info     *info,
+                   UChar *prefixBuffer,
+                   int32_t *prefixBufLen,
+                   UErrorCode *status)
+{
+    if(info->fShowSign) {
+        *prefixBufLen = unum_getTextAttribute(format,
+                                              UNUM_POSITIVE_PREFIX,
+                                              prefixBuffer,
+                                              *prefixBufLen,
+                                              status);
+        if (info->fSpace) {
+            /* Setting UNUM_PLUS_SIGN_SYMBOL affects the exponent too. */
+            /* unum_setSymbol(format, UNUM_PLUS_SIGN_SYMBOL, gSpaceStr, 1, &status); */
+            unum_setTextAttribute(format, UNUM_POSITIVE_PREFIX, gSpaceStr, 1, status);
+        }
+        else {
+            UChar plusSymbol[UPRINTF_SYMBOL_BUFFER_SIZE];
+            int32_t symbolLen;
+
+            symbolLen = unum_getSymbol(format,
+                UNUM_PLUS_SIGN_SYMBOL,
+                plusSymbol,
+                sizeof(plusSymbol)/sizeof(*plusSymbol),
+                status);
+            unum_setTextAttribute(format,
+                UNUM_POSITIVE_PREFIX,
+                plusSymbol,
+                symbolLen,
+                status);
+        }
+    }
+    else {
+        *prefixBufLen = 0;
+    }
+}
+
+static void
+u_printf_reset_sign(UNumberFormat        *format,
+                   const u_printf_spec_info     *info,
+                   UChar *prefixBuffer,
+                   int32_t *prefixBufLen,
+                   UErrorCode *status)
+{
+    if(info->fShowSign) {
+        unum_setTextAttribute(format,
+                              UNUM_POSITIVE_PREFIX,
+                              prefixBuffer,
+                              *prefixBufLen,
+                              status);
+    }
+}
+
+
+/* handle a '%' */
+static int32_t
+u_printf_simple_percent_handler(const u_printf_stream_handler  *handler,
+                                void                           *context,
+                                ULocaleBundle                  *formatBundle,
+                                const u_printf_spec_info       *info,
+                                const ufmt_args                *args)
+{
+    static const UChar PERCENT[] = { UP_PERCENT };
+
+    /* put a single '%' onto the output */
+    return handler->write(context, PERCENT, 1);
+}
+
+/* handle 's' */
+static int32_t
+u_printf_string_handler(const u_printf_stream_handler  *handler,
+                        void                           *context,
+                        ULocaleBundle                  *formatBundle,
+                        const u_printf_spec_info       *info,
+                        const ufmt_args                *args)
+{
+    UChar *s;
+    UChar buffer[UFMT_DEFAULT_BUFFER_SIZE];
+    int32_t len, written;
+    int32_t argSize;
+    const char *arg = (const char*)(args[0].ptrValue);
+
+    /* convert from the default codepage to Unicode */
+    if (arg) {
+        argSize = (int32_t)strlen(arg) + 1;
+        if (argSize >= MAX_UCHAR_BUFFER_SIZE(buffer)) {
+            s = ufmt_defaultCPToUnicode(arg, argSize,
+                    (UChar *)uprv_malloc(MAX_UCHAR_BUFFER_NEEDED(argSize)),
+                    MAX_UCHAR_BUFFER_NEEDED(argSize));
+            if(s == NULL) {
+                return 0;
+            }
+        }
+        else {
+            s = ufmt_defaultCPToUnicode(arg, argSize, buffer,
+                    sizeof(buffer)/sizeof(UChar));
+        }
+    }
+    else {
+        s = (UChar *)gNullStr;
+    }
+    len = u_strlen(s);
+
+    /* width = minimum # of characters to write */
+    /* precision = maximum # of characters to write */
+    if (info->fPrecision != -1 && info->fPrecision < len) {
+        len = info->fPrecision;
+    }
+
+    written = handler->pad_and_justify(context, info, s, len);
+
+    /* clean up */
+    if (gNullStr != s && buffer != s) {
+        uprv_free(s);
+    }
+
+    return written;
+}
+
+static int32_t
+u_printf_char_handler(const u_printf_stream_handler  *handler,
+                      void                           *context,
+                      ULocaleBundle                  *formatBundle,
+                      const u_printf_spec_info       *info,
+                      const ufmt_args                *args)
+{
+    UChar s[UTF_MAX_CHAR_LENGTH+1];
+    int32_t len = 1, written;
+    unsigned char arg = (unsigned char)(args[0].int64Value);
+
+    /* convert from default codepage to Unicode */
+    ufmt_defaultCPToUnicode((const char *)&arg, 2, s, sizeof(s)/sizeof(UChar));
+
+    /* Remember that this may be an MBCS character */
+    if (arg != 0) {
+        len = u_strlen(s);
+    }
+
+    /* width = minimum # of characters to write */
+    /* precision = maximum # of characters to write */
+    /* precision is ignored when handling a char */
+
+    written = handler->pad_and_justify(context, info, s, len);
+
+    return written;
+}
+
+static int32_t
+u_printf_double_handler(const u_printf_stream_handler  *handler,
+                        void                           *context,
+                        ULocaleBundle                  *formatBundle,
+                        const u_printf_spec_info       *info,
+                        const ufmt_args                *args)
+{
+    double        num         = (double) (args[0].doubleValue);
+    UNumberFormat  *format;
+    UChar          result[UPRINTF_BUFFER_SIZE];
+    UChar          prefixBuffer[UPRINTF_BUFFER_SIZE];
+    int32_t        prefixBufferLen = sizeof(prefixBuffer);
+    int32_t        minDecimalDigits;
+    int32_t        maxDecimalDigits;
+    int32_t        resultLen;
+    UErrorCode     status        = U_ZERO_ERROR;
+
+    prefixBuffer[0] = 0;
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLongDouble)
+    num &= DBL_MAX;*/
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* save the formatter's state */
+    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
+    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
+
+    /* set the appropriate flags and number of decimal digits on the formatter */
+    if(info->fPrecision != -1) {
+        /* set the # of decimal digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
+    }
+    else if(info->fAlt) {
+        /* '#' means always show decimal point */
+        /* copy of printf behavior on Solaris - '#' shows 6 digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+    else {
+        /* # of decimal digits is 6 if precision not specified regardless of locale */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+
+    /* set whether to show the sign */
+    if (info->fShowSign) {
+        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
+    }
+
+    /* format the number */
+    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    /* TODO: Is this needed? */
+    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
+    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
+
+    if (info->fShowSign) {
+        /* Reset back to original value regardless of what the error was */
+        UErrorCode localStatus = U_ZERO_ERROR;
+        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+/* HSYS */
+static int32_t
+u_printf_integer_handler(const u_printf_stream_handler  *handler,
+                         void                           *context,
+                         ULocaleBundle                  *formatBundle,
+                         const u_printf_spec_info       *info,
+                         const ufmt_args                *args)
+{
+    int64_t         num        = args[0].int64Value;
+    UNumberFormat   *format;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
+    int32_t         prefixBufferLen = sizeof(prefixBuffer);
+    int32_t         minDigits     = -1;
+    int32_t         resultLen;
+    UErrorCode      status        = U_ZERO_ERROR;
+
+    prefixBuffer[0] = 0;
+
+    /* mask off any necessary bits */
+    if (info->fIsShort)
+        num = (int16_t)num;
+    else if (!info->fIsLongLong)
+        num = (int32_t)num;
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* set the appropriate flags on the formatter */
+
+    /* set the minimum integer digits */
+    if(info->fPrecision != -1) {
+        /* set the minimum # of digits */
+        minDigits = unum_getAttribute(format, UNUM_MIN_INTEGER_DIGITS);
+        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, info->fPrecision);
+    }
+
+    /* set whether to show the sign */
+    if(info->fShowSign) {
+        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
+    }
+
+    /* format the number */
+    resultLen = unum_formatInt64(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    if (minDigits != -1) {
+        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, minDigits);
+    }
+
+    if (info->fShowSign) {
+        /* Reset back to original value regardless of what the error was */
+        UErrorCode localStatus = U_ZERO_ERROR;
+        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+static int32_t
+u_printf_hex_handler(const u_printf_stream_handler  *handler,
+                     void                           *context,
+                     ULocaleBundle                  *formatBundle,
+                     const u_printf_spec_info       *info,
+                     const ufmt_args                *args)
+{
+    int64_t         num        = args[0].int64Value;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    int32_t         len        = UPRINTF_BUFFER_SIZE;
+
+
+    /* mask off any necessary bits */
+    if (info->fIsShort)
+        num &= UINT16_MAX;
+    else if (!info->fIsLongLong)
+        num &= UINT32_MAX;
+
+    /* format the number, preserving the minimum # of digits */
+    ufmt_64tou(result, &len, num, 16,
+        (UBool)(info->fSpec == 0x0078),
+        (info->fPrecision == -1 && info->fZero) ? info->fWidth : info->fPrecision);
+
+    /* convert to alt form, if desired */
+    if(num != 0 && info->fAlt && len < UPRINTF_BUFFER_SIZE - 2) {
+        /* shift the formatted string right by 2 chars */
+        memmove(result + 2, result, len * sizeof(UChar));
+        result[0] = 0x0030;
+        result[1] = info->fSpec;
+        len += 2;
+    }
+
+    return handler->pad_and_justify(context, info, result, len);
+}
+
+static int32_t
+u_printf_octal_handler(const u_printf_stream_handler  *handler,
+                       void                           *context,
+                       ULocaleBundle                  *formatBundle,
+                       const u_printf_spec_info       *info,
+                       const ufmt_args                *args)
+{
+    int64_t         num        = args[0].int64Value;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    int32_t         len        = UPRINTF_BUFFER_SIZE;
+
+
+    /* mask off any necessary bits */
+    if (info->fIsShort)
+        num &= UINT16_MAX;
+    else if (!info->fIsLongLong)
+        num &= UINT32_MAX;
+
+    /* format the number, preserving the minimum # of digits */
+    ufmt_64tou(result, &len, num, 8,
+        FALSE, /* doesn't matter for octal */
+        info->fPrecision == -1 && info->fZero ? info->fWidth : info->fPrecision);
+
+    /* convert to alt form, if desired */
+    if(info->fAlt && result[0] != 0x0030 && len < UPRINTF_BUFFER_SIZE - 1) {
+        /* shift the formatted string right by 1 char */
+        memmove(result + 1, result, len * sizeof(UChar));
+        result[0] = 0x0030;
+        len += 1;
+    }
+
+    return handler->pad_and_justify(context, info, result, len);
+}
+
+static int32_t
+u_printf_uinteger_handler(const u_printf_stream_handler *handler,
+                          void                          *context,
+                          ULocaleBundle                 *formatBundle,
+                          const u_printf_spec_info      *info,
+                          const ufmt_args               *args)
+{
+    int64_t         num        = args[0].int64Value;
+    UNumberFormat   *format;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    int32_t         minDigits     = -1;
+    int32_t         resultLen;
+    UErrorCode      status        = U_ZERO_ERROR;
+
+    /* TODO: Fix this once uint64_t can be formatted. */
+    if (info->fIsShort)
+        num &= UINT16_MAX;
+    else if (!info->fIsLongLong)
+        num &= UINT32_MAX;
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* set the appropriate flags on the formatter */
+
+    /* set the minimum integer digits */
+    if(info->fPrecision != -1) {
+        /* set the minimum # of digits */
+        minDigits = unum_getAttribute(format, UNUM_MIN_INTEGER_DIGITS);
+        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, info->fPrecision);
+    }
+
+    /* To mirror other stdio implementations, we ignore the sign argument */
+
+    /* format the number */
+    resultLen = unum_formatInt64(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    if (minDigits != -1) {
+        unum_setAttribute(format, UNUM_MIN_INTEGER_DIGITS, minDigits);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+static int32_t
+u_printf_pointer_handler(const u_printf_stream_handler  *handler,
+                         void                           *context,
+                         ULocaleBundle                  *formatBundle,
+                         const u_printf_spec_info       *info,
+                         const ufmt_args                *args)
+{
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    int32_t         len  = UPRINTF_BUFFER_SIZE;
+
+    /* format the pointer in hex */
+    ufmt_ptou(result, &len, args[0].ptrValue, TRUE/*, info->fPrecision*/);
+
+    return handler->pad_and_justify(context, info, result, len);
+}
+
+static int32_t
+u_printf_scientific_handler(const u_printf_stream_handler  *handler,
+                            void                           *context,
+                            ULocaleBundle                  *formatBundle,
+                            const u_printf_spec_info       *info,
+                            const ufmt_args                *args)
+{
+    double          num         = (double) (args[0].doubleValue);
+    UNumberFormat   *format;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
+    int32_t         prefixBufferLen = sizeof(prefixBuffer);
+    int32_t         minDecimalDigits;
+    int32_t         maxDecimalDigits;
+    UErrorCode      status        = U_ZERO_ERROR;
+    UChar srcExpBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+    int32_t srcLen, expLen;
+    int32_t resultLen;
+    UChar expBuf[UPRINTF_SYMBOL_BUFFER_SIZE];
+
+    prefixBuffer[0] = 0;
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLongDouble)
+    num &= DBL_MAX;*/
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_SCIENTIFIC);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* set the appropriate flags on the formatter */
+
+    srcLen = unum_getSymbol(format,
+        UNUM_EXPONENTIAL_SYMBOL,
+        srcExpBuf,
+        sizeof(srcExpBuf),
+        &status);
+
+    /* Upper/lower case the e */
+    if (info->fSpec == (UChar)0x65 /* e */) {
+        expLen = u_strToLower(expBuf, (int32_t)sizeof(expBuf),
+            srcExpBuf, srcLen,
+            formatBundle->fLocale,
+            &status);
+    }
+    else {
+        expLen = u_strToUpper(expBuf, (int32_t)sizeof(expBuf),
+            srcExpBuf, srcLen,
+            formatBundle->fLocale,
+            &status);
+    }
+
+    unum_setSymbol(format,
+        UNUM_EXPONENTIAL_SYMBOL,
+        expBuf,
+        expLen,
+        &status);
+
+    /* save the formatter's state */
+    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
+    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
+
+    /* set the appropriate flags and number of decimal digits on the formatter */
+    if(info->fPrecision != -1) {
+        /* set the # of decimal digits */
+        if (info->fOrigSpec == (UChar)0x65 /* e */ || info->fOrigSpec == (UChar)0x45 /* E */) {
+            unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
+        }
+        else {
+            unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, 1);
+            unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, info->fPrecision);
+        }
+    }
+    else if(info->fAlt) {
+        /* '#' means always show decimal point */
+        /* copy of printf behavior on Solaris - '#' shows 6 digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+    else {
+        /* # of decimal digits is 6 if precision not specified */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+
+    /* set whether to show the sign */
+    if (info->fShowSign) {
+        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
+    }
+
+    /* format the number */
+    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    /* TODO: Is this needed? */
+    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
+    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
+
+    /* Since we're the only one using the scientific
+       format, we don't need to save the old exponent value. */
+    /*unum_setSymbol(format,
+        UNUM_EXPONENTIAL_SYMBOL,
+        srcExpBuf,
+        srcLen,
+        &status);*/
+
+    if (info->fShowSign) {
+        /* Reset back to original value regardless of what the error was */
+        UErrorCode localStatus = U_ZERO_ERROR;
+        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+static int32_t
+u_printf_percent_handler(const u_printf_stream_handler  *handler,
+                         void                           *context,
+                         ULocaleBundle                  *formatBundle,
+                         const u_printf_spec_info       *info,
+                         const ufmt_args                *args)
+{
+    double          num         = (double) (args[0].doubleValue);
+    UNumberFormat   *format;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
+    int32_t         prefixBufferLen = sizeof(prefixBuffer);
+    int32_t         minDecimalDigits;
+    int32_t         maxDecimalDigits;
+    int32_t         resultLen;
+    UErrorCode      status        = U_ZERO_ERROR;
+
+    prefixBuffer[0] = 0;
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLongDouble)
+    num &= DBL_MAX;*/
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_PERCENT);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* save the formatter's state */
+    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
+    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
+
+    /* set the appropriate flags and number of decimal digits on the formatter */
+    if(info->fPrecision != -1) {
+        /* set the # of decimal digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
+    }
+    else if(info->fAlt) {
+        /* '#' means always show decimal point */
+        /* copy of printf behavior on Solaris - '#' shows 6 digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+    else {
+        /* # of decimal digits is 6 if precision not specified */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+
+    /* set whether to show the sign */
+    if (info->fShowSign) {
+        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
+    }
+
+    /* format the number */
+    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    /* TODO: Is this needed? */
+    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
+    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
+
+    if (info->fShowSign) {
+        /* Reset back to original value regardless of what the error was */
+        UErrorCode localStatus = U_ZERO_ERROR;
+        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+static int32_t
+u_printf_ustring_handler(const u_printf_stream_handler  *handler,
+                         void                           *context,
+                         ULocaleBundle                  *formatBundle,
+                         const u_printf_spec_info       *info,
+                         const ufmt_args                *args)
+{
+    int32_t len, written;
+    const UChar *arg = (const UChar*)(args[0].ptrValue);
+
+    /* allocate enough space for the buffer */
+    if (arg == NULL) {
+        arg = gNullStr;
+    }
+    len = u_strlen(arg);
+
+    /* width = minimum # of characters to write */
+    /* precision = maximum # of characters to write */
+    if (info->fPrecision != -1 && info->fPrecision < len) {
+        len = info->fPrecision;
+    }
+
+    /* determine if the string should be padded */
+    written = handler->pad_and_justify(context, info, arg, len);
+
+    return written;
+}
+
+static int32_t
+u_printf_uchar_handler(const u_printf_stream_handler  *handler,
+                       void                           *context,
+                       ULocaleBundle                  *formatBundle,
+                       const u_printf_spec_info       *info,
+                       const ufmt_args                *args)
+{
+    int32_t written = 0;
+    UChar arg = (UChar)(args[0].int64Value);
+
+    /* width = minimum # of characters to write */
+    /* precision = maximum # of characters to write */
+    /* precision is ignored when handling a uchar */
+
+    /* determine if the string should be padded */
+    written = handler->pad_and_justify(context, info, &arg, 1);
+
+    return written;
+}
+
+static int32_t
+u_printf_scidbl_handler(const u_printf_stream_handler  *handler,
+                        void                           *context,
+                        ULocaleBundle                  *formatBundle,
+                        const u_printf_spec_info       *info,
+                        const ufmt_args                *args)
+{
+    u_printf_spec_info scidbl_info;
+    double      num = args[0].doubleValue;
+    int32_t     retVal;
+
+    memcpy(&scidbl_info, info, sizeof(u_printf_spec_info));
+
+    /* determine whether to use 'd', 'e' or 'f' notation */
+    if (scidbl_info.fPrecision == -1 && num == uprv_trunc(num))
+    {
+        /* use 'f' notation */
+        scidbl_info.fSpec = 0x0066;
+        scidbl_info.fPrecision = 0;
+        /* call the double handler */
+        retVal = u_printf_double_handler(handler, context, formatBundle, &scidbl_info, args);
+    }
+    else if(num < 0.0001 || (scidbl_info.fPrecision < 1 && 1000000.0 <= num)
+        || (scidbl_info.fPrecision != -1 && num > uprv_pow10(scidbl_info.fPrecision)))
+    {
+        /* use 'e' or 'E' notation */
+        scidbl_info.fSpec = scidbl_info.fSpec - 2;
+        if (scidbl_info.fPrecision == -1) {
+            scidbl_info.fPrecision = 5;
+        }
+        /* call the scientific handler */
+        retVal = u_printf_scientific_handler(handler, context, formatBundle, &scidbl_info, args);
+    }
+    else {
+        UNumberFormat   *format = u_locbund_getNumberFormat(formatBundle, UNUM_DECIMAL);
+        int32_t maxSigDecimalDigits = unum_getAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS);
+        int32_t significantDigits = scidbl_info.fPrecision;
+
+        /* use 'f' notation */
+        scidbl_info.fSpec = 0x0066;
+        if (significantDigits == -1) {
+            significantDigits = 6;
+        }
+        unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, TRUE);
+        unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, significantDigits);
+        /* call the double handler */
+        retVal = u_printf_double_handler(handler, context, formatBundle, &scidbl_info, args);
+        unum_setAttribute(format, UNUM_MAX_SIGNIFICANT_DIGITS, maxSigDecimalDigits);
+        unum_setAttribute(format, UNUM_SIGNIFICANT_DIGITS_USED, FALSE);
+    }
+    return retVal;
+}
+
+static int32_t
+u_printf_count_handler(const u_printf_stream_handler  *handler,
+                       void                           *context,
+                       ULocaleBundle                  *formatBundle,
+                       const u_printf_spec_info       *info,
+                       const ufmt_args                *args)
+{
+    int32_t *count = (int32_t*)(args[0].ptrValue);
+
+    /* in the special case of count, the u_printf_spec_info's width */
+    /* will contain the # of chars written thus far */
+    *count = info->fWidth;
+
+    return 0;
+}
+
+static int32_t
+u_printf_spellout_handler(const u_printf_stream_handler *handler,
+                          void                          *context,
+                          ULocaleBundle                 *formatBundle,
+                          const u_printf_spec_info      *info,
+                          const ufmt_args               *args)
+{
+    double          num         = (double) (args[0].doubleValue);
+    UNumberFormat   *format;
+    UChar           result[UPRINTF_BUFFER_SIZE];
+    UChar           prefixBuffer[UPRINTF_BUFFER_SIZE];
+    int32_t         prefixBufferLen = sizeof(prefixBuffer);
+    int32_t         minDecimalDigits;
+    int32_t         maxDecimalDigits;
+    int32_t         resultLen;
+    UErrorCode      status        = U_ZERO_ERROR;
+
+    prefixBuffer[0] = 0;
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLongDouble)
+    num &= DBL_MAX;*/
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(formatBundle, UNUM_SPELLOUT);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* save the formatter's state */
+    minDecimalDigits = unum_getAttribute(format, UNUM_MIN_FRACTION_DIGITS);
+    maxDecimalDigits = unum_getAttribute(format, UNUM_MAX_FRACTION_DIGITS);
+
+    /* set the appropriate flags and number of decimal digits on the formatter */
+    if(info->fPrecision != -1) {
+        /* set the # of decimal digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, info->fPrecision);
+    }
+    else if(info->fAlt) {
+        /* '#' means always show decimal point */
+        /* copy of printf behavior on Solaris - '#' shows 6 digits */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+    else {
+        /* # of decimal digits is 6 if precision not specified */
+        unum_setAttribute(format, UNUM_FRACTION_DIGITS, 6);
+    }
+
+    /* set whether to show the sign */
+    if (info->fShowSign) {
+        u_printf_set_sign(format, info, prefixBuffer, &prefixBufferLen, &status);
+    }
+
+    /* format the number */
+    resultLen = unum_formatDouble(format, num, result, UPRINTF_BUFFER_SIZE, 0, &status);
+
+    if (U_FAILURE(status)) {
+        resultLen = 0;
+    }
+
+    /* restore the number format */
+    /* TODO: Is this needed? */
+    unum_setAttribute(format, UNUM_MIN_FRACTION_DIGITS, minDecimalDigits);
+    unum_setAttribute(format, UNUM_MAX_FRACTION_DIGITS, maxDecimalDigits);
+
+    if (info->fShowSign) {
+        /* Reset back to original value regardless of what the error was */
+        UErrorCode localStatus = U_ZERO_ERROR;
+        u_printf_reset_sign(format, info, prefixBuffer, &prefixBufferLen, &localStatus);
+    }
+
+    return handler->pad_and_justify(context, info, result, resultLen);
+}
+
+/* Use US-ASCII characters only for formatting. Most codepages have
+ characters 20-7F from Unicode. Using any other codepage specific
+ characters will make it very difficult to format the string on
+ non-Unicode machines */
+static const u_printf_info g_u_printf_infos[UPRINTF_NUM_FMT_HANDLERS] = {
+/* 0x20 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_SIMPLE_PERCENT,UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x30 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x40 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR,
+    UFMT_EMPTY,         UFMT_SCIENTIFIC,    UFMT_EMPTY,         UFMT_SCIDBL,
+#ifdef U_USE_OBSOLETE_IO_FORMATTING
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR/*deprecated*/,
+#else
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+#endif
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x50 */
+    UFMT_PERCENT,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_USTRING,
+#ifdef U_USE_OBSOLETE_IO_FORMATTING
+    UFMT_EMPTY,         UFMT_USTRING/*deprecated*/,UFMT_SPELLOUT,      UFMT_EMPTY,
+#else
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SPELLOUT,      UFMT_EMPTY,
+#endif
+    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x60 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_CHAR,
+    UFMT_INT,           UFMT_SCIENTIFIC,    UFMT_DOUBLE,        UFMT_SCIDBL,
+    UFMT_EMPTY,         UFMT_INT,           UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_COUNT,         UFMT_OCTAL,
+
+/* 0x70 */
+    UFMT_POINTER,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_STRING,
+    UFMT_EMPTY,         UFMT_UINT,          UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+};
+
+/* flag characters for uprintf */
+#define FLAG_MINUS 0x002D
+#define FLAG_PLUS 0x002B
+#define FLAG_SPACE 0x0020
+#define FLAG_POUND 0x0023
+#define FLAG_ZERO  0x0030
+#define FLAG_PAREN 0x0028
+
+#define ISFLAG(s)    (s) == FLAG_MINUS || \
+            (s) == FLAG_PLUS || \
+            (s) == FLAG_SPACE || \
+            (s) == FLAG_POUND || \
+            (s) == FLAG_ZERO || \
+            (s) == FLAG_PAREN
+
+/* special characters for uprintf */
+#define SPEC_ASTERISK 0x002A
+#define SPEC_DOLLARSIGN 0x0024
+#define SPEC_PERIOD 0x002E
+#define SPEC_PERCENT 0x0025
+
+/* unicode digits */
+#define DIGIT_ZERO 0x0030
+#define DIGIT_ONE 0x0031
+#define DIGIT_TWO 0x0032
+#define DIGIT_THREE 0x0033
+#define DIGIT_FOUR 0x0034
+#define DIGIT_FIVE 0x0035
+#define DIGIT_SIX 0x0036
+#define DIGIT_SEVEN 0x0037
+#define DIGIT_EIGHT 0x0038
+#define DIGIT_NINE 0x0039
+
+#define ISDIGIT(s)    (s) == DIGIT_ZERO || \
+            (s) == DIGIT_ONE || \
+            (s) == DIGIT_TWO || \
+            (s) == DIGIT_THREE || \
+            (s) == DIGIT_FOUR || \
+            (s) == DIGIT_FIVE || \
+            (s) == DIGIT_SIX || \
+            (s) == DIGIT_SEVEN || \
+            (s) == DIGIT_EIGHT || \
+            (s) == DIGIT_NINE
+
+/* u_printf modifiers */
+#define MOD_H 0x0068
+#define MOD_LOWERL 0x006C
+#define MOD_L 0x004C
+
+#define ISMOD(s)    (s) == MOD_H || \
+            (s) == MOD_LOWERL || \
+            (s) == MOD_L
+
+/* We parse the argument list in Unicode */
+U_CFUNC int32_t
+u_printf_parse(const u_printf_stream_handler *streamHandler,
+               const UChar     *fmt,
+               void            *context,
+               u_localized_print_string *locStringContext,
+               ULocaleBundle   *formatBundle,
+               int32_t         *written,
+               va_list         ap)
+{
+    uint16_t         handlerNum;
+    ufmt_args        args;
+    ufmt_type_info   argType;
+    u_printf_handler *handler;
+    u_printf_spec    spec;
+    u_printf_spec_info *info = &(spec.fInfo);
+
+    const UChar *alias = fmt;
+    const UChar *backup;
+    const UChar *lastAlias;
+
+    /* iterate through the pattern */
+    while(!locStringContext || locStringContext->available > 0) {
+
+        /* find the next '%' */
+        lastAlias = alias;
+        while(*alias != UP_PERCENT && *alias != 0x0000) {
+            alias++;
+        }
+
+        /* write any characters before the '%' */
+        if(alias > lastAlias) {
+            *written += (streamHandler->write)(context, lastAlias, (int32_t)(alias - lastAlias));
+        }
+
+        /* break if at end of string */
+        if(*alias == 0x0000) {
+            break;
+        }
+
+        /* initialize spec to default values */
+        spec.fWidthPos     = -1;
+        spec.fPrecisionPos = -1;
+        spec.fArgPos       = -1;
+
+        uprv_memset(info, 0, sizeof(*info));
+        info->fPrecision    = -1;
+        info->fWidth        = -1;
+        info->fPadChar      = 0x0020;
+
+        /* skip over the initial '%' */
+        alias++;
+
+        /* Check for positional argument */
+        if(ISDIGIT(*alias)) {
+
+            /* Save the current position */
+            backup = alias;
+
+            /* handle positional parameters */
+            if(ISDIGIT(*alias)) {
+                spec.fArgPos = (int) (*alias++ - DIGIT_ZERO);
+
+                while(ISDIGIT(*alias)) {
+                    spec.fArgPos *= 10;
+                    spec.fArgPos += (int) (*alias++ - DIGIT_ZERO);
+                }
+            }
+
+            /* if there is no '$', don't read anything */
+            if(*alias != SPEC_DOLLARSIGN) {
+                spec.fArgPos = -1;
+                alias = backup;
+            }
+            /* munge the '$' */
+            else
+                alias++;
+        }
+
+        /* Get any format flags */
+        while(ISFLAG(*alias)) {
+            switch(*alias++) {
+
+                /* left justify */
+            case FLAG_MINUS:
+                info->fLeft = TRUE;
+                break;
+
+                /* always show sign */
+            case FLAG_PLUS:
+                info->fShowSign = TRUE;
+                break;
+
+                /* use space if no sign present */
+            case FLAG_SPACE:
+                info->fShowSign = TRUE;
+                info->fSpace = TRUE;
+                break;
+
+                /* use alternate form */
+            case FLAG_POUND:
+                info->fAlt = TRUE;
+                break;
+
+                /* pad with leading zeroes */
+            case FLAG_ZERO:
+                info->fZero = TRUE;
+                info->fPadChar = 0x0030;
+                break;
+
+                /* pad character specified */
+            case FLAG_PAREN:
+
+                /* TODO test that all four are numbers */
+                /* first four characters are hex values for pad char */
+                info->fPadChar = (UChar)ufmt_digitvalue(*alias++);
+                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+                info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*alias++));
+
+                /* final character is ignored */
+                alias++;
+
+                break;
+            }
+        }
+
+        /* Get the width */
+
+        /* width is specified out of line */
+        if(*alias == SPEC_ASTERISK) {
+
+            info->fWidth = -2;
+
+            /* Skip the '*' */
+            alias++;
+
+            /* Save the current position */
+            backup = alias;
+
+            /* handle positional parameters */
+            if(ISDIGIT(*alias)) {
+                spec.fWidthPos = (int) (*alias++ - DIGIT_ZERO);
+
+                while(ISDIGIT(*alias)) {
+                    spec.fWidthPos *= 10;
+                    spec.fWidthPos += (int) (*alias++ - DIGIT_ZERO);
+                }
+            }
+
+            /* if there is no '$', don't read anything */
+            if(*alias != SPEC_DOLLARSIGN) {
+                spec.fWidthPos = -1;
+                alias = backup;
+            }
+            /* munge the '$' */
+            else
+                alias++;
+        }
+        /* read the width, if present */
+        else if(ISDIGIT(*alias)){
+            info->fWidth = (int) (*alias++ - DIGIT_ZERO);
+
+            while(ISDIGIT(*alias)) {
+                info->fWidth *= 10;
+                info->fWidth += (int) (*alias++ - DIGIT_ZERO);
+            }
+        }
+
+        /* Get the precision */
+
+        if(*alias == SPEC_PERIOD) {
+
+            /* eat up the '.' */
+            alias++;
+
+            /* precision is specified out of line */
+            if(*alias == SPEC_ASTERISK) {
+
+                info->fPrecision = -2;
+
+                /* Skip the '*' */
+                alias++;
+
+                /* save the current position */
+                backup = alias;
+
+                /* handle positional parameters */
+                if(ISDIGIT(*alias)) {
+                    spec.fPrecisionPos = (int) (*alias++ - DIGIT_ZERO);
+
+                    while(ISDIGIT(*alias)) {
+                        spec.fPrecisionPos *= 10;
+                        spec.fPrecisionPos += (int) (*alias++ - DIGIT_ZERO);
+                    }
+
+                    /* if there is no '$', don't read anything */
+                    if(*alias != SPEC_DOLLARSIGN) {
+                        spec.fPrecisionPos = -1;
+                        alias = backup;
+                    }
+                    else {
+                        /* munge the '$' */
+                        alias++;
+                    }
+                }
+            }
+            /* read the precision */
+            else if(ISDIGIT(*alias)){
+                info->fPrecision = (int) (*alias++ - DIGIT_ZERO);
+
+                while(ISDIGIT(*alias)) {
+                    info->fPrecision *= 10;
+                    info->fPrecision += (int) (*alias++ - DIGIT_ZERO);
+                }
+            }
+        }
+
+        /* Get any modifiers */
+        if(ISMOD(*alias)) {
+            switch(*alias++) {
+
+                /* short */
+            case MOD_H:
+                info->fIsShort = TRUE;
+                break;
+
+                /* long or long long */
+            case MOD_LOWERL:
+                if(*alias == MOD_LOWERL) {
+                    info->fIsLongLong = TRUE;
+                    /* skip over the next 'l' */
+                    alias++;
+                }
+                else
+                    info->fIsLong = TRUE;
+                break;
+
+                /* long double */
+            case MOD_L:
+                info->fIsLongDouble = TRUE;
+                break;
+            }
+        }
+
+        /* finally, get the specifier letter */
+        info->fSpec = *alias++;
+        info->fOrigSpec = info->fSpec;
+
+        /* fill in the precision and width, if specified out of line */
+
+        /* width specified out of line */
+        if(spec.fInfo.fWidth == -2) {
+            if(spec.fWidthPos == -1) {
+                /* read the width from the argument list */
+                info->fWidth = va_arg(ap, int32_t);
+            }
+            /* else handle positional parameter */
+
+            /* if it's negative, take the absolute value and set left alignment */
+            if(info->fWidth < 0) {
+                info->fWidth *= -1; /* Make positive */
+                info->fLeft = TRUE;
+            }
+        }
+
+        /* precision specified out of line */
+        if(info->fPrecision == -2) {
+            if(spec.fPrecisionPos == -1) {
+                /* read the precision from the argument list */
+                info->fPrecision = va_arg(ap, int32_t);
+            }
+            /* else handle positional parameter */
+
+            /* if it's negative, set it to zero */
+            if(info->fPrecision < 0)
+                info->fPrecision = 0;
+        }
+
+        handlerNum = (uint16_t)(info->fSpec - UPRINTF_BASE_FMT_HANDLERS);
+        if (handlerNum < UPRINTF_NUM_FMT_HANDLERS) {
+            /* query the info function for argument information */
+            argType = g_u_printf_infos[ handlerNum ].info;
+            switch(argType) {
+            case ufmt_count:
+                /* set the spec's width to the # of chars written */
+                info->fWidth = *written;
+                /* fall through to set the pointer */
+            case ufmt_string:
+            case ufmt_ustring:
+            case ufmt_pointer:
+                args.ptrValue = va_arg(ap, void*);
+                break;
+            case ufmt_char:
+            case ufmt_uchar:
+            case ufmt_int:
+                if (info->fIsLongLong) {
+                    args.int64Value = va_arg(ap, int64_t);
+                }
+                else {
+                    args.int64Value = va_arg(ap, int32_t);
+                }
+                break;
+            case ufmt_float:
+                args.floatValue = (float) va_arg(ap, double);
+                break;
+            case ufmt_double:
+                args.doubleValue = va_arg(ap, double);
+                break;
+            default:
+                /* else args is ignored */
+                args.ptrValue = NULL;
+                break;
+            }
+
+            /* call the handler function */
+            handler = g_u_printf_infos[ handlerNum ].handler;
+            if(handler != 0) {
+                *written += (*handler)(streamHandler, context, formatBundle, info, &args);
+            }
+            else {
+                /* just echo unknown tags */
+                *written += (streamHandler->write)(context, fmt, (int32_t)(alias - lastAlias));
+            }
+        }
+        else {
+            /* just echo unknown tags */
+            *written += (streamHandler->write)(context, fmt, (int32_t)(alias - lastAlias));
+        }
+    }
+    /* return # of characters in this format that have been parsed. */
+    return (int32_t)(alias - fmt);
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */


Property changes on: trunk/source/io/uprntf_p.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uscanf.c
===================================================================
--- trunk/source/io/uscanf.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uscanf.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,106 +1,106 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File uscanf.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/02/98    stephen        Creation.
-*   03/13/99    stephen     Modified for new C API.
-******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/putil.h"
-#include "unicode/ustdio.h"
-#include "unicode/ustring.h"
-#include "uscanf.h"
-#include "ufile.h"
-#include "ufmt_cmn.h"
-
-#include "cmemory.h"
-#include "cstring.h"
-
-
-U_CAPI int32_t U_EXPORT2
-u_fscanf(UFILE        *f,
-         const char    *patternSpecification,
-         ... )
-{
-    va_list ap;
-    int32_t converted;
-
-    va_start(ap, patternSpecification);
-    converted = u_vfscanf(f, patternSpecification, ap);
-    va_end(ap);
-
-    return converted;
-}
-
-U_CAPI int32_t U_EXPORT2
-u_fscanf_u(UFILE        *f,
-           const UChar    *patternSpecification,
-           ... )
-{
-    va_list ap;
-    int32_t converted;
-
-    va_start(ap, patternSpecification);
-    converted = u_vfscanf_u(f, patternSpecification, ap);
-    va_end(ap);
-
-    return converted;
-}
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vfscanf(UFILE        *f,
-          const char    *patternSpecification,
-          va_list        ap)
-{
-    int32_t converted;
-    UChar *pattern;
-    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
-    int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
-
-    /* convert from the default codepage to Unicode */
-    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
-        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
-        if(pattern == 0) {
-            return 0;
-        }
-    }
-    else {
-        pattern = patBuffer;
-    }
-    u_charsToUChars(patternSpecification, pattern, size);
-
-    /* do the work */
-    converted = u_vfscanf_u(f, pattern, ap);
-
-    /* clean up */
-    if (pattern != patBuffer) {
-        uprv_free(pattern);
-    }
-
-    return converted;
-}
-
-U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_vfscanf_u(UFILE       *f,
-            const UChar *patternSpecification,
-            va_list     ap)
-{
-    return u_scanf_parse(f, patternSpecification, ap);
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File uscanf.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/02/98    stephen        Creation.
+*   03/13/99    stephen     Modified for new C API.
+******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/putil.h"
+#include "unicode/ustdio.h"
+#include "unicode/ustring.h"
+#include "uscanf.h"
+#include "ufile.h"
+#include "ufmt_cmn.h"
+
+#include "cmemory.h"
+#include "cstring.h"
+
+
+U_CAPI int32_t U_EXPORT2
+u_fscanf(UFILE        *f,
+         const char    *patternSpecification,
+         ... )
+{
+    va_list ap;
+    int32_t converted;
+
+    va_start(ap, patternSpecification);
+    converted = u_vfscanf(f, patternSpecification, ap);
+    va_end(ap);
+
+    return converted;
+}
+
+U_CAPI int32_t U_EXPORT2
+u_fscanf_u(UFILE        *f,
+           const UChar    *patternSpecification,
+           ... )
+{
+    va_list ap;
+    int32_t converted;
+
+    va_start(ap, patternSpecification);
+    converted = u_vfscanf_u(f, patternSpecification, ap);
+    va_end(ap);
+
+    return converted;
+}
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vfscanf(UFILE        *f,
+          const char    *patternSpecification,
+          va_list        ap)
+{
+    int32_t converted;
+    UChar *pattern;
+    UChar patBuffer[UFMT_DEFAULT_BUFFER_SIZE];
+    int32_t size = (int32_t)uprv_strlen(patternSpecification) + 1;
+
+    /* convert from the default codepage to Unicode */
+    if (size >= MAX_UCHAR_BUFFER_SIZE(patBuffer)) {
+        pattern = (UChar *)uprv_malloc(size * sizeof(UChar));
+        if(pattern == 0) {
+            return 0;
+        }
+    }
+    else {
+        pattern = patBuffer;
+    }
+    u_charsToUChars(patternSpecification, pattern, size);
+
+    /* do the work */
+    converted = u_vfscanf_u(f, pattern, ap);
+
+    /* clean up */
+    if (pattern != patBuffer) {
+        uprv_free(pattern);
+    }
+
+    return converted;
+}
+
+U_CAPI int32_t  U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_vfscanf_u(UFILE       *f,
+            const UChar *patternSpecification,
+            va_list     ap)
+{
+    return u_scanf_parse(f, patternSpecification, ap);
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+


Property changes on: trunk/source/io/uscanf.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uscanf.h
===================================================================
--- trunk/source/io/uscanf.h	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uscanf.h	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,36 +1,36 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2004, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File uscanf.h
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/02/98    stephen        Creation.
-*   03/13/99    stephen     Modified for new C API.
-******************************************************************************
-*/
-
-#ifndef USCANF_H
-#define USCANF_H
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/ustdio.h"
-
-U_CFUNC int32_t
-u_scanf_parse(UFILE     *f,
-            const UChar *patternSpecification,
-            va_list     ap);
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
-
-#endif
-
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2004, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File uscanf.h
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/02/98    stephen        Creation.
+*   03/13/99    stephen     Modified for new C API.
+******************************************************************************
+*/
+
+#ifndef USCANF_H
+#define USCANF_H
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/ustdio.h"
+
+U_CFUNC int32_t
+u_scanf_parse(UFILE     *f,
+            const UChar *patternSpecification,
+            va_list     ap);
+
+#endif /* #if !UCONFIG_NO_FORMATTING */
+
+#endif
+


Property changes on: trunk/source/io/uscanf.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/uscanf_p.c
===================================================================
--- trunk/source/io/uscanf_p.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/uscanf_p.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,1371 +1,1371 @@
-/*
-*******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-*******************************************************************************
-*
-* File uscnnf_p.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   12/02/98    stephen        Creation.
-*   03/13/99    stephen     Modified for new C API.
-*******************************************************************************
-*/
-
-#include "unicode/utypes.h"
-
-#if !UCONFIG_NO_FORMATTING
-
-#include "unicode/uchar.h"
-#include "unicode/ustring.h"
-#include "unicode/unum.h"
-#include "unicode/udat.h"
-#include "unicode/uset.h"
-#include "uscanf.h"
-#include "ufmt_cmn.h"
-#include "ufile.h"
-#include "locbund.h"
-
-#include "cmemory.h"
-#include "ustr_cnv.h"
-
-/* flag characters for u_scanf */
-#define FLAG_ASTERISK 0x002A
-#define FLAG_PAREN 0x0028
-
-#define ISFLAG(s)    (s) == FLAG_ASTERISK || \
-            (s) == FLAG_PAREN
-
-/* special characters for u_scanf */
-#define SPEC_DOLLARSIGN 0x0024
-
-/* unicode digits */
-#define DIGIT_ZERO 0x0030
-#define DIGIT_ONE 0x0031
-#define DIGIT_TWO 0x0032
-#define DIGIT_THREE 0x0033
-#define DIGIT_FOUR 0x0034
-#define DIGIT_FIVE 0x0035
-#define DIGIT_SIX 0x0036
-#define DIGIT_SEVEN 0x0037
-#define DIGIT_EIGHT 0x0038
-#define DIGIT_NINE 0x0039
-
-#define ISDIGIT(s)    (s) == DIGIT_ZERO || \
-            (s) == DIGIT_ONE || \
-            (s) == DIGIT_TWO || \
-            (s) == DIGIT_THREE || \
-            (s) == DIGIT_FOUR || \
-            (s) == DIGIT_FIVE || \
-            (s) == DIGIT_SIX || \
-            (s) == DIGIT_SEVEN || \
-            (s) == DIGIT_EIGHT || \
-            (s) == DIGIT_NINE
-
-/* u_scanf modifiers */
-#define MOD_H 0x0068
-#define MOD_LOWERL 0x006C
-#define MOD_L 0x004C
-
-#define ISMOD(s)    (s) == MOD_H || \
-            (s) == MOD_LOWERL || \
-            (s) == MOD_L
-
-/**
- * Struct encapsulating a single uscanf format specification.
- */
-typedef struct u_scanf_spec_info {
-    int32_t fWidth;         /* Width  */
-
-    UChar   fSpec;          /* Format specification  */
-
-    UChar   fPadChar;       /* Padding character  */
-
-    UBool   fSkipArg;       /* TRUE if arg should be skipped */
-    UBool   fIsLongDouble;  /* L flag  */
-    UBool   fIsShort;       /* h flag  */
-    UBool   fIsLong;        /* l flag  */
-    UBool   fIsLongLong;    /* ll flag  */
-    UBool   fIsString;      /* TRUE if this is a NULL-terminated string. */
-} u_scanf_spec_info;
-
-
-/**
- * Struct encapsulating a single u_scanf format specification.
- */
-typedef struct u_scanf_spec {
-    u_scanf_spec_info    fInfo;        /* Information on this spec */
-    int32_t        fArgPos;    /* Position of data in arg list */
-} u_scanf_spec;
-
-/**
- * Parse a single u_scanf format specifier in Unicode.
- * @param fmt A pointer to a '%' character in a u_scanf format specification.
- * @param spec A pointer to a <TT>u_scanf_spec</TT> to receive the parsed
- * format specifier.
- * @return The number of characters contained in this specifier.
- */
-static int32_t
-u_scanf_parse_spec (const UChar     *fmt,
-            u_scanf_spec    *spec)
-{
-    const UChar *s = fmt;
-    const UChar *backup;
-    u_scanf_spec_info *info = &(spec->fInfo);
-
-    /* initialize spec to default values */
-    spec->fArgPos             = -1;
-
-    info->fWidth        = -1;
-    info->fSpec         = 0x0000;
-    info->fPadChar      = 0x0020;
-    info->fSkipArg      = FALSE;
-    info->fIsLongDouble = FALSE;
-    info->fIsShort      = FALSE;
-    info->fIsLong       = FALSE;
-    info->fIsLongLong   = FALSE;
-    info->fIsString     = TRUE;
-
-
-    /* skip over the initial '%' */
-    s++;
-
-    /* Check for positional argument */
-    if(ISDIGIT(*s)) {
-
-        /* Save the current position */
-        backup = s;
-
-        /* handle positional parameters */
-        if(ISDIGIT(*s)) {
-            spec->fArgPos = (int) (*s++ - DIGIT_ZERO);
-
-            while(ISDIGIT(*s)) {
-                spec->fArgPos *= 10;
-                spec->fArgPos += (int) (*s++ - DIGIT_ZERO);
-            }
-        }
-
-        /* if there is no '$', don't read anything */
-        if(*s != SPEC_DOLLARSIGN) {
-            spec->fArgPos = -1;
-            s = backup;
-        }
-        /* munge the '$' */
-        else
-            s++;
-    }
-
-    /* Get any format flags */
-    while(ISFLAG(*s)) {
-        switch(*s++) {
-
-            /* skip argument */
-        case FLAG_ASTERISK:
-            info->fSkipArg = TRUE;
-            break;
-
-            /* pad character specified */
-        case FLAG_PAREN:
-
-            /* first four characters are hex values for pad char */
-            info->fPadChar = (UChar)ufmt_digitvalue(*s++);
-            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
-            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
-            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
-
-            /* final character is ignored */
-            s++;
-
-            break;
-        }
-    }
-
-    /* Get the width */
-    if(ISDIGIT(*s)){
-        info->fWidth = (int) (*s++ - DIGIT_ZERO);
-
-        while(ISDIGIT(*s)) {
-            info->fWidth *= 10;
-            info->fWidth += (int) (*s++ - DIGIT_ZERO);
-        }
-    }
-
-    /* Get any modifiers */
-    if(ISMOD(*s)) {
-        switch(*s++) {
-
-            /* short */
-        case MOD_H:
-            info->fIsShort = TRUE;
-            break;
-
-            /* long or long long */
-        case MOD_LOWERL:
-            if(*s == MOD_LOWERL) {
-                info->fIsLongLong = TRUE;
-                /* skip over the next 'l' */
-                s++;
-            }
-            else
-                info->fIsLong = TRUE;
-            break;
-
-            /* long double */
-        case MOD_L:
-            info->fIsLongDouble = TRUE;
-            break;
-        }
-    }
-
-    /* finally, get the specifier letter */
-    info->fSpec = *s++;
-
-    /* return # of characters in this specifier */
-    return (int32_t)(s - fmt);
-}
-
-#define UP_PERCENT 0x0025
-
-
-/* ANSI style formatting */
-/* Use US-ASCII characters only for formatting */
-
-/* % */
-#define UFMT_SIMPLE_PERCENT {ufmt_simple_percent, u_scanf_simple_percent_handler}
-/* s */
-#define UFMT_STRING         {ufmt_string, u_scanf_string_handler}
-/* c */
-#define UFMT_CHAR           {ufmt_string, u_scanf_char_handler}
-/* d, i */
-#define UFMT_INT            {ufmt_int, u_scanf_integer_handler}
-/* u */
-#define UFMT_UINT           {ufmt_int, u_scanf_uinteger_handler}
-/* o */
-#define UFMT_OCTAL          {ufmt_int, u_scanf_octal_handler}
-/* x, X */
-#define UFMT_HEX            {ufmt_int, u_scanf_hex_handler}
-/* f */
-#define UFMT_DOUBLE         {ufmt_double, u_scanf_double_handler}
-/* e, E */
-#define UFMT_SCIENTIFIC     {ufmt_double, u_scanf_scientific_handler}
-/* g, G */
-#define UFMT_SCIDBL         {ufmt_double, u_scanf_scidbl_handler}
-/* n */
-#define UFMT_COUNT          {ufmt_count, u_scanf_count_handler}
-/* [ */
-#define UFMT_SCANSET        {ufmt_string, u_scanf_scanset_handler}
-
-/* non-ANSI extensions */
-/* Use US-ASCII characters only for formatting */
-
-/* p */
-#define UFMT_POINTER        {ufmt_pointer, u_scanf_pointer_handler}
-/* V */
-#define UFMT_SPELLOUT       {ufmt_double, u_scanf_spellout_handler}
-/* P */
-#define UFMT_PERCENT        {ufmt_double, u_scanf_percent_handler}
-/* C  K is old format */
-#define UFMT_UCHAR          {ufmt_uchar, u_scanf_uchar_handler}
-/* S  U is old format */
-#define UFMT_USTRING        {ufmt_ustring, u_scanf_ustring_handler}
-
-
-#define UFMT_EMPTY {ufmt_empty, NULL}
-
-/**
- * A u_scanf handler function.  
- * A u_scanf handler is responsible for handling a single u_scanf 
- * format specification, for example 'd' or 's'.
- * @param stream The UFILE to which to write output.
- * @param info A pointer to a <TT>u_scanf_spec_info</TT> struct containing
- * information on the format specification.
- * @param args A pointer to the argument data
- * @param fmt A pointer to the first character in the format string
- * following the spec.
- * @param fmtConsumed On output, set to the number of characters consumed
- * in <TT>fmt</TT>. Do nothing, if the argument isn't variable width.
- * @param argConverted The number of arguments converted and assigned, or -1 if an
- * error occurred.
- * @return The number of code points consumed during reading.
- */
-typedef int32_t (*u_scanf_handler) (UFILE   *stream,
-                   u_scanf_spec_info  *info,
-                   ufmt_args                *args,
-                   const UChar              *fmt,
-                   int32_t                  *fmtConsumed,
-                   int32_t                  *argConverted);
-
-typedef struct u_scanf_info {
-    ufmt_type_info info;
-    u_scanf_handler handler;
-} u_scanf_info;
-
-#define USCANF_NUM_FMT_HANDLERS 108
-#define USCANF_SYMBOL_BUFFER_SIZE 8
-
-/* We do not use handlers for 0-0x1f */
-#define USCANF_BASE_FMT_HANDLERS 0x20
-
-
-static int32_t
-u_scanf_skip_leading_ws(UFILE   *input,
-                        UChar   pad)
-{
-    UChar   c;
-    int32_t count = 0;
-    UBool isNotEOF;
-
-    /* skip all leading ws in the input */
-    while( (isNotEOF = ufile_getch(input, &c)) && (c == pad || u_isWhitespace(c)) )
-    {
-        count++;
-    }
-
-    /* put the final character back on the input */
-    if(isNotEOF)
-        u_fungetc(c, input);
-
-    return count;
-}
-
-/* TODO: Is always skipping the prefix symbol as a positive sign a good idea in all locales? */
-static int32_t
-u_scanf_skip_leading_positive_sign(UFILE   *input,
-                                   UNumberFormat *format,
-                                   UErrorCode *status)
-{
-    UChar   c;
-    int32_t count = 0;
-    UBool isNotEOF;
-    UChar plusSymbol[USCANF_SYMBOL_BUFFER_SIZE];
-    int32_t symbolLen;
-    UErrorCode localStatus = U_ZERO_ERROR;
-
-    if (U_SUCCESS(*status)) {
-        symbolLen = unum_getSymbol(format,
-            UNUM_PLUS_SIGN_SYMBOL,
-            plusSymbol,
-            sizeof(plusSymbol)/sizeof(*plusSymbol),
-            &localStatus);
-
-        if (U_SUCCESS(localStatus)) {
-            /* skip all leading ws in the input */
-            while( (isNotEOF = ufile_getch(input, &c)) && (count < symbolLen && c == plusSymbol[count]) )
-            {
-                count++;
-            }
-
-            /* put the final character back on the input */
-            if(isNotEOF) {
-                u_fungetc(c, input);
-            }
-        }
-    }
-
-    return count;
-}
-
-static int32_t 
-u_scanf_simple_percent_handler(UFILE        *input,
-                               u_scanf_spec_info *info,
-                               ufmt_args    *args,
-                               const UChar  *fmt,
-                               int32_t      *fmtConsumed,
-                               int32_t      *argConverted)
-{
-    /* make sure the next character in the input is a percent */
-    *argConverted = 0;
-    if(u_fgetc(input) != 0x0025) {
-        *argConverted = -1;
-    }
-    return 1;
-}
-
-static int32_t
-u_scanf_count_handler(UFILE         *input,
-                      u_scanf_spec_info *info,
-                      ufmt_args     *args,
-                      const UChar   *fmt,
-                      int32_t       *fmtConsumed,
-                      int32_t       *argConverted)
-{
-    /* in the special case of count, the u_scanf_spec_info's width */
-    /* will contain the # of items converted thus far */
-    if (!info->fSkipArg) {
-        if (info->fIsShort)
-            *(int16_t*)(args[0].ptrValue) = (int16_t)(UINT16_MAX & info->fWidth);
-        else if (info->fIsLongLong)
-            *(int64_t*)(args[0].ptrValue) = info->fWidth;
-        else
-            *(int32_t*)(args[0].ptrValue) = (int32_t)(UINT32_MAX & info->fWidth);
-    }
-    *argConverted = 0;
-
-    /* we converted 0 args */
-    return 0;
-}
-
-static int32_t
-u_scanf_double_handler(UFILE        *input,
-                       u_scanf_spec_info *info,
-                       ufmt_args    *args,
-                       const UChar  *fmt,
-                       int32_t      *fmtConsumed,
-                       int32_t      *argConverted)
-{
-    int32_t         len;
-    double          num;
-    UNumberFormat   *format;
-    int32_t         parsePos    = 0;
-    int32_t         skipped;
-    UErrorCode      status      = U_ZERO_ERROR;
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
-
-    /* parse the number */
-    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
-
-    if (!info->fSkipArg) {
-        if (info->fIsLong)
-            *(double*)(args[0].ptrValue) = num;
-        else if (info->fIsLongDouble)
-            *(long double*)(args[0].ptrValue) = num;
-        else
-            *(float*)(args[0].ptrValue) = (float)num;
-    }
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLong_double)
-    num &= DBL_MAX;*/
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += parsePos;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos + skipped;
-}
-
-static int32_t
-u_scanf_scientific_handler(UFILE        *input,
-                           u_scanf_spec_info *info,
-                           ufmt_args    *args,
-                           const UChar  *fmt,
-                           int32_t      *fmtConsumed,
-                           int32_t      *argConverted)
-{
-    int32_t         len;
-    double          num;
-    UNumberFormat   *format;
-    int32_t         parsePos    = 0;
-    int32_t         skipped;
-    UErrorCode      status      = U_ZERO_ERROR;
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SCIENTIFIC);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
-
-    /* parse the number */
-    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
-
-    if (!info->fSkipArg) {
-        if (info->fIsLong)
-            *(double*)(args[0].ptrValue) = num;
-        else if (info->fIsLongDouble)
-            *(long double*)(args[0].ptrValue) = num;
-        else
-            *(float*)(args[0].ptrValue) = (float)num;
-    }
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLong_double)
-    num &= DBL_MAX;*/
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += parsePos;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos + skipped;
-}
-
-static int32_t
-u_scanf_scidbl_handler(UFILE        *input,
-                       u_scanf_spec_info *info,
-                       ufmt_args    *args,
-                       const UChar  *fmt,
-                       int32_t      *fmtConsumed,
-                       int32_t      *argConverted)
-{
-    int32_t       len;
-    double        num;
-    UNumberFormat *scientificFormat, *genericFormat;
-    /*int32_t       scientificResult, genericResult;*/
-    double        scientificResult, genericResult;
-    int32_t       scientificParsePos = 0, genericParsePos = 0, parsePos = 0;
-    int32_t       skipped;
-    UErrorCode    scientificStatus = U_ZERO_ERROR;
-    UErrorCode    genericStatus = U_ZERO_ERROR;
-
-
-    /* since we can't determine by scanning the characters whether */
-    /* a number was formatted in the 'f' or 'g' styles, parse the */
-    /* string with both formatters, and assume whichever one */
-    /* parsed the most is the correct formatter to use */
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatters */
-    scientificFormat = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SCIENTIFIC);
-    genericFormat = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(scientificFormat == 0 || genericFormat == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    skipped += u_scanf_skip_leading_positive_sign(input, genericFormat, &genericStatus);
-
-    /* parse the number using each format*/
-
-    scientificResult = unum_parseDouble(scientificFormat, input->str.fPos, len,
-        &scientificParsePos, &scientificStatus);
-
-    genericResult = unum_parseDouble(genericFormat, input->str.fPos, len,
-        &genericParsePos, &genericStatus);
-
-    /* determine which parse made it farther */
-    if(scientificParsePos > genericParsePos) {
-        /* stash the result in num */
-        num = scientificResult;
-        /* update the input's position to reflect consumed data */
-        parsePos += scientificParsePos;
-    }
-    else {
-        /* stash the result in num */
-        num = genericResult;
-        /* update the input's position to reflect consumed data */
-        parsePos += genericParsePos;
-    }
-    input->str.fPos += parsePos;
-
-    if (!info->fSkipArg) {
-        if (info->fIsLong)
-            *(double*)(args[0].ptrValue) = num;
-        else if (info->fIsLongDouble)
-            *(long double*)(args[0].ptrValue) = num;
-        else
-            *(float*)(args[0].ptrValue) = (float)num;
-    }
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLong_double)
-    num &= DBL_MAX;*/
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos + skipped;
-}
-
-static int32_t
-u_scanf_integer_handler(UFILE       *input,
-                        u_scanf_spec_info *info,
-                        ufmt_args   *args,
-                        const UChar *fmt,
-                        int32_t     *fmtConsumed,
-                        int32_t     *argConverted)
-{
-    int32_t         len;
-    void            *num        = (void*) (args[0].ptrValue);
-    UNumberFormat   *format;
-    int32_t         parsePos    = 0;
-    int32_t         skipped;
-    UErrorCode      status      = U_ZERO_ERROR;
-    int64_t         result;
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
-
-    /* parse the number */
-    result = unum_parseInt64(format, input->str.fPos, len, &parsePos, &status);
-
-    /* mask off any necessary bits */
-    if (!info->fSkipArg) {
-        if (info->fIsShort)
-            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
-        else if (info->fIsLongLong)
-            *(int64_t*)num = result;
-        else
-            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
-    }
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += parsePos;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos + skipped;
-}
-
-static int32_t
-u_scanf_uinteger_handler(UFILE          *input,
-                         u_scanf_spec_info *info,
-                         ufmt_args      *args,
-                         const UChar    *fmt,
-                         int32_t        *fmtConsumed,
-                         int32_t        *argConverted)
-{
-    /* TODO Fix this when Numberformat handles uint64_t */
-    return u_scanf_integer_handler(input, info, args, fmt, fmtConsumed, argConverted);
-}
-
-static int32_t
-u_scanf_percent_handler(UFILE       *input,
-                        u_scanf_spec_info *info,
-                        ufmt_args   *args,
-                        const UChar *fmt,
-                        int32_t     *fmtConsumed,
-                        int32_t     *argConverted)
-{
-    int32_t         len;
-    double          num;
-    UNumberFormat   *format;
-    int32_t         parsePos    = 0;
-    int32_t         skipped;
-    UErrorCode      status      = U_ZERO_ERROR;
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_PERCENT);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
-
-    /* parse the number */
-    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
-
-    if (!info->fSkipArg) {
-        *(double*)(args[0].ptrValue) = num;
-    }
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLong_double)
-    num &= DBL_MAX;*/
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += parsePos;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos;
-}
-
-static int32_t
-u_scanf_string_handler(UFILE        *input,
-                       u_scanf_spec_info *info,
-                       ufmt_args    *args,
-                       const UChar  *fmt,
-                       int32_t      *fmtConsumed,
-                       int32_t      *argConverted)
-{
-    const UChar *source;
-    UConverter  *conv;
-    char        *arg    = (char*)(args[0].ptrValue);
-    char        *alias  = arg;
-    char        *limit;
-    UErrorCode  status  = U_ZERO_ERROR;
-    int32_t     count;
-    int32_t     skipped = 0;
-    UChar       c;
-    UBool       isNotEOF = FALSE;
-
-    /* skip all ws in the input */
-    if (info->fIsString) {
-        skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-    }
-
-    /* get the string one character at a time, truncating to the width */
-    count = 0;
-
-    /* open the default converter */
-    conv = u_getDefaultConverter(&status);
-
-    if(U_FAILURE(status))
-        return -1;
-
-    while( (info->fWidth == -1 || count < info->fWidth) 
-        && (isNotEOF = ufile_getch(input, &c))
-        && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
-    {
-
-        if (!info->fSkipArg) {
-            /* put the character from the input onto the target */
-            source = &c;
-            /* Since we do this one character at a time, do it this way. */
-            if (info->fWidth > 0) {
-                limit = alias + info->fWidth - count;
-            }
-            else {
-                limit = alias + ucnv_getMaxCharSize(conv);
-            }
-
-            /* convert the character to the default codepage */
-            ucnv_fromUnicode(conv, &alias, limit, &source, source + 1,
-                NULL, TRUE, &status);
-
-            if(U_FAILURE(status)) {
-                /* clean up */
-                u_releaseDefaultConverter(conv);
-                return -1;
-            }
-        }
-
-        /* increment the count */
-        ++count;
-    }
-
-    /* put the final character we read back on the input */
-    if (!info->fSkipArg) {
-        if ((info->fWidth == -1 || count < info->fWidth) && isNotEOF)
-            u_fungetc(c, input);
-
-        /* add the terminator */
-        if (info->fIsString) {
-            *alias = 0x00;
-        }
-    }
-
-    /* clean up */
-    u_releaseDefaultConverter(conv);
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return count + skipped;
-}
-
-static int32_t
-u_scanf_char_handler(UFILE          *input,
-                     u_scanf_spec_info *info,
-                     ufmt_args      *args,
-                     const UChar    *fmt,
-                     int32_t        *fmtConsumed,
-                     int32_t        *argConverted)
-{
-    if (info->fWidth < 0) {
-        info->fWidth = 1;
-    }
-    info->fIsString = FALSE;
-    return u_scanf_string_handler(input, info, args, fmt, fmtConsumed, argConverted);
-}
-
-static int32_t
-u_scanf_ustring_handler(UFILE       *input,
-                        u_scanf_spec_info *info,
-                        ufmt_args   *args,
-                        const UChar *fmt,
-                        int32_t     *fmtConsumed,
-                        int32_t     *argConverted)
-{
-    UChar   *arg     = (UChar*)(args[0].ptrValue);
-    UChar   *alias     = arg;
-    int32_t count;
-    int32_t skipped = 0;
-    UChar   c;
-    UBool   isNotEOF = FALSE;
-
-    /* skip all ws in the input */
-    if (info->fIsString) {
-        skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-    }
-
-    /* get the string one character at a time, truncating to the width */
-    count = 0;
-
-    while( (info->fWidth == -1 || count < info->fWidth)
-        && (isNotEOF = ufile_getch(input, &c))
-        && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
-    {
-
-        /* put the character from the input onto the target */
-        if (!info->fSkipArg) {
-            *alias++ = c;
-        }
-
-        /* increment the count */
-        ++count;
-    }
-
-    /* put the final character we read back on the input */
-    if (!info->fSkipArg) {
-        if((info->fWidth == -1 || count < info->fWidth) && isNotEOF) {
-            u_fungetc(c, input);
-        }
-
-        /* add the terminator */
-        if (info->fIsString) {
-            *alias = 0x0000;
-        }
-    }
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return count + skipped;
-}
-
-static int32_t
-u_scanf_uchar_handler(UFILE         *input,
-                      u_scanf_spec_info *info,
-                      ufmt_args     *args,
-                      const UChar   *fmt,
-                      int32_t       *fmtConsumed,
-                      int32_t       *argConverted)
-{
-    if (info->fWidth < 0) {
-        info->fWidth = 1;
-    }
-    info->fIsString = FALSE;
-    return u_scanf_ustring_handler(input, info, args, fmt, fmtConsumed, argConverted);
-}
-
-static int32_t
-u_scanf_spellout_handler(UFILE          *input,
-                         u_scanf_spec_info *info,
-                         ufmt_args      *args,
-                         const UChar    *fmt,
-                         int32_t        *fmtConsumed,
-                         int32_t        *argConverted)
-{
-    int32_t         len;
-    double          num;
-    UNumberFormat   *format;
-    int32_t         parsePos    = 0;
-    int32_t         skipped;
-    UErrorCode      status      = U_ZERO_ERROR;
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* get the formatter */
-    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SPELLOUT);
-
-    /* handle error */
-    if(format == 0)
-        return 0;
-
-    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
-    /* This is not applicable to RBNF. */
-    /*skipped += u_scanf_skip_leading_positive_sign(input, format, &status);*/
-
-    /* parse the number */
-    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
-
-    if (!info->fSkipArg) {
-        *(double*)(args[0].ptrValue) = num;
-    }
-
-    /* mask off any necessary bits */
-    /*  if(! info->fIsLong_double)
-    num &= DBL_MAX;*/
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += parsePos;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return parsePos + skipped;
-}
-
-static int32_t
-u_scanf_hex_handler(UFILE       *input,
-                    u_scanf_spec_info *info,
-                    ufmt_args   *args,
-                    const UChar *fmt,
-                    int32_t     *fmtConsumed,
-                    int32_t     *argConverted)
-{
-    int32_t     len;
-    int32_t     skipped;
-    void        *num    = (void*) (args[0].ptrValue);
-    int64_t     result;
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* check for alternate form */
-    if( *(input->str.fPos) == 0x0030 &&
-        (*(input->str.fPos + 1) == 0x0078 || *(input->str.fPos + 1) == 0x0058) ) {
-
-        /* skip the '0' and 'x' or 'X' if present */
-        input->str.fPos += 2;
-        len -= 2;
-    }
-
-    /* parse the number */
-    result = ufmt_uto64(input->str.fPos, &len, 16);
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += len;
-
-    /* mask off any necessary bits */
-    if (!info->fSkipArg) {
-        if (info->fIsShort)
-            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
-        else if (info->fIsLongLong)
-            *(int64_t*)num = result;
-        else
-            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
-    }
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return len + skipped;
-}
-
-static int32_t
-u_scanf_octal_handler(UFILE         *input,
-                      u_scanf_spec_info *info,
-                      ufmt_args     *args,
-                      const UChar   *fmt,
-                      int32_t       *fmtConsumed,
-                      int32_t       *argConverted)
-{
-    int32_t     len;
-    int32_t     skipped;
-    void        *num         = (void*) (args[0].ptrValue);
-    int64_t     result;
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1)
-        len = ufmt_min(len, info->fWidth);
-
-    /* parse the number */
-    result = ufmt_uto64(input->str.fPos, &len, 8);
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += len;
-
-    /* mask off any necessary bits */
-    if (!info->fSkipArg) {
-        if (info->fIsShort)
-            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
-        else if (info->fIsLongLong)
-            *(int64_t*)num = result;
-        else
-            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
-    }
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return len + skipped;
-}
-
-static int32_t
-u_scanf_pointer_handler(UFILE       *input,
-                        u_scanf_spec_info *info,
-                        ufmt_args   *args,
-                        const UChar *fmt,
-                        int32_t     *fmtConsumed,
-                        int32_t     *argConverted)
-{
-    int32_t len;
-    int32_t skipped;
-    void    *result;
-    void    **p     = (void**)(args[0].ptrValue);
-
-
-    /* skip all ws in the input */
-    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
-
-    /* fill the input's internal buffer */
-    ufile_fill_uchar_buffer(input);
-
-    /* determine the size of the input's buffer */
-    len = (int32_t)(input->str.fLimit - input->str.fPos);
-
-    /* truncate to the width, if specified */
-    if(info->fWidth != -1) {
-        len = ufmt_min(len, info->fWidth);
-    }
-
-    /* Make sure that we don't consume too much */
-    if (len > (int32_t)(sizeof(void*)*2)) {
-        len = (int32_t)(sizeof(void*)*2);
-    }
-
-    /* parse the pointer - assign to temporary value */
-    result = ufmt_utop(input->str.fPos, &len);
-
-    if (!info->fSkipArg) {
-        *p = result;
-    }
-
-    /* update the input's position to reflect consumed data */
-    input->str.fPos += len;
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return len + skipped;
-}
-
-static int32_t
-u_scanf_scanset_handler(UFILE       *input,
-                        u_scanf_spec_info *info,
-                        ufmt_args   *args,
-                        const UChar *fmt,
-                        int32_t     *fmtConsumed,
-                        int32_t     *argConverted)
-{
-    USet        *scanset;
-    UErrorCode  status = U_ZERO_ERROR;
-    int32_t     chLeft = INT32_MAX;
-    UChar32     c;
-    UChar       *alias = (UChar*) (args[0].ptrValue);
-    UBool       isNotEOF = FALSE;
-    UBool       readCharacter = FALSE;
-
-    /* Create an empty set */
-    scanset = uset_open(0, -1);
-
-    /* Back up one to get the [ */
-    fmt--;
-
-    /* truncate to the width, if specified and alias the target */
-    if(info->fWidth >= 0) {
-        chLeft = info->fWidth;
-    }
-
-    /* parse the scanset from the fmt string */
-    *fmtConsumed = uset_applyPattern(scanset, fmt, -1, 0, &status);
-
-    /* verify that the parse was successful */
-    if (U_SUCCESS(status)) {
-        c=0;
-
-        /* grab characters one at a time and make sure they are in the scanset */
-        while(chLeft > 0) {
-            if ((isNotEOF = ufile_getch32(input, &c)) && uset_contains(scanset, c)) {
-                readCharacter = TRUE;
-                if (!info->fSkipArg) {
-                    int32_t idx = 0;
-                    UBool isError = FALSE;
-
-                    U16_APPEND(alias, idx, chLeft, c, isError);
-                    if (isError) {
-                        break;
-                    }
-                    alias += idx;
-                }
-                chLeft -= (1 + U_IS_SUPPLEMENTARY(c));
-            }
-            else {
-                /* if the character's not in the scanset, break out */
-                break;
-            }
-        }
-
-        /* put the final character we read back on the input */
-        if(isNotEOF && chLeft > 0) {
-            u_fungetc(c, input);
-        }
-    }
-
-    uset_close(scanset);
-
-    /* if we didn't match at least 1 character, fail */
-    if(!readCharacter)
-        return -1;
-    /* otherwise, add the terminator */
-    else if (!info->fSkipArg) {
-        *alias = 0x00;
-    }
-
-    /* we converted 1 arg */
-    *argConverted = !info->fSkipArg;
-    return (info->fWidth >= 0 ? info->fWidth : INT32_MAX) - chLeft;
-}
-
-/* Use US-ASCII characters only for formatting. Most codepages have
- characters 20-7F from Unicode. Using any other codepage specific
- characters will make it very difficult to format the string on
- non-Unicode machines */
-static const u_scanf_info g_u_scanf_infos[USCANF_NUM_FMT_HANDLERS] = {
-/* 0x20 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_SIMPLE_PERCENT,UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x30 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x40 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR,
-    UFMT_EMPTY,         UFMT_SCIENTIFIC,    UFMT_EMPTY,         UFMT_SCIDBL,
-#ifdef U_USE_OBSOLETE_IO_FORMATTING
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR/*deprecated*/,
-#else
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-#endif
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x50 */
-    UFMT_PERCENT,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_USTRING,
-#ifdef U_USE_OBSOLETE_IO_FORMATTING
-    UFMT_EMPTY,         UFMT_USTRING/*deprecated*/,UFMT_SPELLOUT,      UFMT_EMPTY,
-#else
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SPELLOUT,      UFMT_EMPTY,
-#endif
-    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SCANSET,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-
-/* 0x60 */
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_CHAR,
-    UFMT_INT,           UFMT_SCIENTIFIC,    UFMT_DOUBLE,        UFMT_SCIDBL,
-    UFMT_EMPTY,         UFMT_INT,           UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_COUNT,         UFMT_OCTAL,
-
-/* 0x70 */
-    UFMT_POINTER,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_STRING,
-    UFMT_EMPTY,         UFMT_UINT,          UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
-};
-
-U_CFUNC int32_t
-u_scanf_parse(UFILE     *f,
-            const UChar *patternSpecification,
-            va_list     ap)
-{
-    const UChar     *alias;
-    int32_t         count, converted, argConsumed, cpConsumed;
-    uint16_t        handlerNum;
-
-    ufmt_args       args;
-    u_scanf_spec    spec;
-    ufmt_type_info  info;
-    u_scanf_handler handler;
-
-    /* alias the pattern */
-    alias = patternSpecification;
-
-    /* haven't converted anything yet */
-    argConsumed = 0;
-    converted = 0;
-    cpConsumed = 0;
-
-    /* iterate through the pattern */
-    for(;;) {
-
-        /* match any characters up to the next '%' */
-        while(*alias != UP_PERCENT && *alias != 0x0000 && u_fgetc(f) == *alias) {
-            alias++;
-        }
-
-        /* if we aren't at a '%', or if we're at end of string, break*/
-        if(*alias != UP_PERCENT || *alias == 0x0000)
-            break;
-
-        /* parse the specifier */
-        count = u_scanf_parse_spec(alias, &spec);
-
-        /* update the pointer in pattern */
-        alias += count;
-
-        handlerNum = (uint16_t)(spec.fInfo.fSpec - USCANF_BASE_FMT_HANDLERS);
-        if (handlerNum < USCANF_NUM_FMT_HANDLERS) {
-            /* skip the argument, if necessary */
-            /* query the info function for argument information */
-            info = g_u_scanf_infos[ handlerNum ].info;
-            if (info != ufmt_count && u_feof(f)) {
-                break;
-            }
-            else if(spec.fInfo.fSkipArg) {
-                args.ptrValue = NULL;
-            }
-            else {
-                switch(info) {
-                case ufmt_count:
-                    /* set the spec's width to the # of items converted */
-                    spec.fInfo.fWidth = cpConsumed;
-                    /* fall through to next case */
-                case ufmt_char:
-                case ufmt_uchar:
-                case ufmt_int:
-                case ufmt_string:
-                case ufmt_ustring:
-                case ufmt_pointer:
-                case ufmt_float:
-                case ufmt_double:
-                    args.ptrValue = va_arg(ap, void*);
-                    break;
-
-                default:
-                    /* else args is ignored */
-                    args.ptrValue = NULL;
-                    break;
-                }
-            }
-
-            /* call the handler function */
-            handler = g_u_scanf_infos[ handlerNum ].handler;
-            if(handler != 0) {
-
-                /* reset count to 1 so that += for alias works. */
-                count = 1;
-
-                cpConsumed += (*handler)(f, &spec.fInfo, &args, alias, &count, &argConsumed);
-
-                /* if the handler encountered an error condition, break */
-                if(argConsumed < 0) {
-                    converted = -1;
-                    break;
-                }
-
-                /* add to the # of items converted */
-                converted += argConsumed;
-
-                /* update the pointer in pattern */
-                alias += count-1;
-            }
-            /* else do nothing */
-        }
-        /* else do nothing */
-
-        /* just ignore unknown tags */
-    }
-
-    /* return # of items converted */
-    return converted;
-}
-
-#endif /* #if !UCONFIG_NO_FORMATTING */
+/*
+*******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+*******************************************************************************
+*
+* File uscnnf_p.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   12/02/98    stephen        Creation.
+*   03/13/99    stephen     Modified for new C API.
+*******************************************************************************
+*/
+
+#include "unicode/utypes.h"
+
+#if !UCONFIG_NO_FORMATTING
+
+#include "unicode/uchar.h"
+#include "unicode/ustring.h"
+#include "unicode/unum.h"
+#include "unicode/udat.h"
+#include "unicode/uset.h"
+#include "uscanf.h"
+#include "ufmt_cmn.h"
+#include "ufile.h"
+#include "locbund.h"
+
+#include "cmemory.h"
+#include "ustr_cnv.h"
+
+/* flag characters for u_scanf */
+#define FLAG_ASTERISK 0x002A
+#define FLAG_PAREN 0x0028
+
+#define ISFLAG(s)    (s) == FLAG_ASTERISK || \
+            (s) == FLAG_PAREN
+
+/* special characters for u_scanf */
+#define SPEC_DOLLARSIGN 0x0024
+
+/* unicode digits */
+#define DIGIT_ZERO 0x0030
+#define DIGIT_ONE 0x0031
+#define DIGIT_TWO 0x0032
+#define DIGIT_THREE 0x0033
+#define DIGIT_FOUR 0x0034
+#define DIGIT_FIVE 0x0035
+#define DIGIT_SIX 0x0036
+#define DIGIT_SEVEN 0x0037
+#define DIGIT_EIGHT 0x0038
+#define DIGIT_NINE 0x0039
+
+#define ISDIGIT(s)    (s) == DIGIT_ZERO || \
+            (s) == DIGIT_ONE || \
+            (s) == DIGIT_TWO || \
+            (s) == DIGIT_THREE || \
+            (s) == DIGIT_FOUR || \
+            (s) == DIGIT_FIVE || \
+            (s) == DIGIT_SIX || \
+            (s) == DIGIT_SEVEN || \
+            (s) == DIGIT_EIGHT || \
+            (s) == DIGIT_NINE
+
+/* u_scanf modifiers */
+#define MOD_H 0x0068
+#define MOD_LOWERL 0x006C
+#define MOD_L 0x004C
+
+#define ISMOD(s)    (s) == MOD_H || \
+            (s) == MOD_LOWERL || \
+            (s) == MOD_L
+
+/**
+ * Struct encapsulating a single uscanf format specification.
+ */
+typedef struct u_scanf_spec_info {
+    int32_t fWidth;         /* Width  */
+
+    UChar   fSpec;          /* Format specification  */
+
+    UChar   fPadChar;       /* Padding character  */
+
+    UBool   fSkipArg;       /* TRUE if arg should be skipped */
+    UBool   fIsLongDouble;  /* L flag  */
+    UBool   fIsShort;       /* h flag  */
+    UBool   fIsLong;        /* l flag  */
+    UBool   fIsLongLong;    /* ll flag  */
+    UBool   fIsString;      /* TRUE if this is a NULL-terminated string. */
+} u_scanf_spec_info;
+
+
+/**
+ * Struct encapsulating a single u_scanf format specification.
+ */
+typedef struct u_scanf_spec {
+    u_scanf_spec_info    fInfo;        /* Information on this spec */
+    int32_t        fArgPos;    /* Position of data in arg list */
+} u_scanf_spec;
+
+/**
+ * Parse a single u_scanf format specifier in Unicode.
+ * @param fmt A pointer to a '%' character in a u_scanf format specification.
+ * @param spec A pointer to a <TT>u_scanf_spec</TT> to receive the parsed
+ * format specifier.
+ * @return The number of characters contained in this specifier.
+ */
+static int32_t
+u_scanf_parse_spec (const UChar     *fmt,
+            u_scanf_spec    *spec)
+{
+    const UChar *s = fmt;
+    const UChar *backup;
+    u_scanf_spec_info *info = &(spec->fInfo);
+
+    /* initialize spec to default values */
+    spec->fArgPos             = -1;
+
+    info->fWidth        = -1;
+    info->fSpec         = 0x0000;
+    info->fPadChar      = 0x0020;
+    info->fSkipArg      = FALSE;
+    info->fIsLongDouble = FALSE;
+    info->fIsShort      = FALSE;
+    info->fIsLong       = FALSE;
+    info->fIsLongLong   = FALSE;
+    info->fIsString     = TRUE;
+
+
+    /* skip over the initial '%' */
+    s++;
+
+    /* Check for positional argument */
+    if(ISDIGIT(*s)) {
+
+        /* Save the current position */
+        backup = s;
+
+        /* handle positional parameters */
+        if(ISDIGIT(*s)) {
+            spec->fArgPos = (int) (*s++ - DIGIT_ZERO);
+
+            while(ISDIGIT(*s)) {
+                spec->fArgPos *= 10;
+                spec->fArgPos += (int) (*s++ - DIGIT_ZERO);
+            }
+        }
+
+        /* if there is no '$', don't read anything */
+        if(*s != SPEC_DOLLARSIGN) {
+            spec->fArgPos = -1;
+            s = backup;
+        }
+        /* munge the '$' */
+        else
+            s++;
+    }
+
+    /* Get any format flags */
+    while(ISFLAG(*s)) {
+        switch(*s++) {
+
+            /* skip argument */
+        case FLAG_ASTERISK:
+            info->fSkipArg = TRUE;
+            break;
+
+            /* pad character specified */
+        case FLAG_PAREN:
+
+            /* first four characters are hex values for pad char */
+            info->fPadChar = (UChar)ufmt_digitvalue(*s++);
+            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+            info->fPadChar = (UChar)((info->fPadChar * 16) + ufmt_digitvalue(*s++));
+
+            /* final character is ignored */
+            s++;
+
+            break;
+        }
+    }
+
+    /* Get the width */
+    if(ISDIGIT(*s)){
+        info->fWidth = (int) (*s++ - DIGIT_ZERO);
+
+        while(ISDIGIT(*s)) {
+            info->fWidth *= 10;
+            info->fWidth += (int) (*s++ - DIGIT_ZERO);
+        }
+    }
+
+    /* Get any modifiers */
+    if(ISMOD(*s)) {
+        switch(*s++) {
+
+            /* short */
+        case MOD_H:
+            info->fIsShort = TRUE;
+            break;
+
+            /* long or long long */
+        case MOD_LOWERL:
+            if(*s == MOD_LOWERL) {
+                info->fIsLongLong = TRUE;
+                /* skip over the next 'l' */
+                s++;
+            }
+            else
+                info->fIsLong = TRUE;
+            break;
+
+            /* long double */
+        case MOD_L:
+            info->fIsLongDouble = TRUE;
+            break;
+        }
+    }
+
+    /* finally, get the specifier letter */
+    info->fSpec = *s++;
+
+    /* return # of characters in this specifier */
+    return (int32_t)(s - fmt);
+}
+
+#define UP_PERCENT 0x0025
+
+
+/* ANSI style formatting */
+/* Use US-ASCII characters only for formatting */
+
+/* % */
+#define UFMT_SIMPLE_PERCENT {ufmt_simple_percent, u_scanf_simple_percent_handler}
+/* s */
+#define UFMT_STRING         {ufmt_string, u_scanf_string_handler}
+/* c */
+#define UFMT_CHAR           {ufmt_string, u_scanf_char_handler}
+/* d, i */
+#define UFMT_INT            {ufmt_int, u_scanf_integer_handler}
+/* u */
+#define UFMT_UINT           {ufmt_int, u_scanf_uinteger_handler}
+/* o */
+#define UFMT_OCTAL          {ufmt_int, u_scanf_octal_handler}
+/* x, X */
+#define UFMT_HEX            {ufmt_int, u_scanf_hex_handler}
+/* f */
+#define UFMT_DOUBLE         {ufmt_double, u_scanf_double_handler}
+/* e, E */
+#define UFMT_SCIENTIFIC     {ufmt_double, u_scanf_scientific_handler}
+/* g, G */
+#define UFMT_SCIDBL         {ufmt_double, u_scanf_scidbl_handler}
+/* n */
+#define UFMT_COUNT          {ufmt_count, u_scanf_count_handler}
+/* [ */
+#define UFMT_SCANSET        {ufmt_string, u_scanf_scanset_handler}
+
+/* non-ANSI extensions */
+/* Use US-ASCII characters only for formatting */
+
+/* p */
+#define UFMT_POINTER        {ufmt_pointer, u_scanf_pointer_handler}
+/* V */
+#define UFMT_SPELLOUT       {ufmt_double, u_scanf_spellout_handler}
+/* P */
+#define UFMT_PERCENT        {ufmt_double, u_scanf_percent_handler}
+/* C  K is old format */
+#define UFMT_UCHAR          {ufmt_uchar, u_scanf_uchar_handler}
+/* S  U is old format */
+#define UFMT_USTRING        {ufmt_ustring, u_scanf_ustring_handler}
+
+
+#define UFMT_EMPTY {ufmt_empty, NULL}
+
+/**
+ * A u_scanf handler function.  
+ * A u_scanf handler is responsible for handling a single u_scanf 
+ * format specification, for example 'd' or 's'.
+ * @param stream The UFILE to which to write output.
+ * @param info A pointer to a <TT>u_scanf_spec_info</TT> struct containing
+ * information on the format specification.
+ * @param args A pointer to the argument data
+ * @param fmt A pointer to the first character in the format string
+ * following the spec.
+ * @param fmtConsumed On output, set to the number of characters consumed
+ * in <TT>fmt</TT>. Do nothing, if the argument isn't variable width.
+ * @param argConverted The number of arguments converted and assigned, or -1 if an
+ * error occurred.
+ * @return The number of code points consumed during reading.
+ */
+typedef int32_t (*u_scanf_handler) (UFILE   *stream,
+                   u_scanf_spec_info  *info,
+                   ufmt_args                *args,
+                   const UChar              *fmt,
+                   int32_t                  *fmtConsumed,
+                   int32_t                  *argConverted);
+
+typedef struct u_scanf_info {
+    ufmt_type_info info;
+    u_scanf_handler handler;
+} u_scanf_info;
+
+#define USCANF_NUM_FMT_HANDLERS 108
+#define USCANF_SYMBOL_BUFFER_SIZE 8
+
+/* We do not use handlers for 0-0x1f */
+#define USCANF_BASE_FMT_HANDLERS 0x20
+
+
+static int32_t
+u_scanf_skip_leading_ws(UFILE   *input,
+                        UChar   pad)
+{
+    UChar   c;
+    int32_t count = 0;
+    UBool isNotEOF;
+
+    /* skip all leading ws in the input */
+    while( (isNotEOF = ufile_getch(input, &c)) && (c == pad || u_isWhitespace(c)) )
+    {
+        count++;
+    }
+
+    /* put the final character back on the input */
+    if(isNotEOF)
+        u_fungetc(c, input);
+
+    return count;
+}
+
+/* TODO: Is always skipping the prefix symbol as a positive sign a good idea in all locales? */
+static int32_t
+u_scanf_skip_leading_positive_sign(UFILE   *input,
+                                   UNumberFormat *format,
+                                   UErrorCode *status)
+{
+    UChar   c;
+    int32_t count = 0;
+    UBool isNotEOF;
+    UChar plusSymbol[USCANF_SYMBOL_BUFFER_SIZE];
+    int32_t symbolLen;
+    UErrorCode localStatus = U_ZERO_ERROR;
+
+    if (U_SUCCESS(*status)) {
+        symbolLen = unum_getSymbol(format,
+            UNUM_PLUS_SIGN_SYMBOL,
+            plusSymbol,
+            sizeof(plusSymbol)/sizeof(*plusSymbol),
+            &localStatus);
+
+        if (U_SUCCESS(localStatus)) {
+            /* skip all leading ws in the input */
+            while( (isNotEOF = ufile_getch(input, &c)) && (count < symbolLen && c == plusSymbol[count]) )
+            {
+                count++;
+            }
+
+            /* put the final character back on the input */
+            if(isNotEOF) {
+                u_fungetc(c, input);
+            }
+        }
+    }
+
+    return count;
+}
+
+static int32_t 
+u_scanf_simple_percent_handler(UFILE        *input,
+                               u_scanf_spec_info *info,
+                               ufmt_args    *args,
+                               const UChar  *fmt,
+                               int32_t      *fmtConsumed,
+                               int32_t      *argConverted)
+{
+    /* make sure the next character in the input is a percent */
+    *argConverted = 0;
+    if(u_fgetc(input) != 0x0025) {
+        *argConverted = -1;
+    }
+    return 1;
+}
+
+static int32_t
+u_scanf_count_handler(UFILE         *input,
+                      u_scanf_spec_info *info,
+                      ufmt_args     *args,
+                      const UChar   *fmt,
+                      int32_t       *fmtConsumed,
+                      int32_t       *argConverted)
+{
+    /* in the special case of count, the u_scanf_spec_info's width */
+    /* will contain the # of items converted thus far */
+    if (!info->fSkipArg) {
+        if (info->fIsShort)
+            *(int16_t*)(args[0].ptrValue) = (int16_t)(UINT16_MAX & info->fWidth);
+        else if (info->fIsLongLong)
+            *(int64_t*)(args[0].ptrValue) = info->fWidth;
+        else
+            *(int32_t*)(args[0].ptrValue) = (int32_t)(UINT32_MAX & info->fWidth);
+    }
+    *argConverted = 0;
+
+    /* we converted 0 args */
+    return 0;
+}
+
+static int32_t
+u_scanf_double_handler(UFILE        *input,
+                       u_scanf_spec_info *info,
+                       ufmt_args    *args,
+                       const UChar  *fmt,
+                       int32_t      *fmtConsumed,
+                       int32_t      *argConverted)
+{
+    int32_t         len;
+    double          num;
+    UNumberFormat   *format;
+    int32_t         parsePos    = 0;
+    int32_t         skipped;
+    UErrorCode      status      = U_ZERO_ERROR;
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
+
+    /* parse the number */
+    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
+
+    if (!info->fSkipArg) {
+        if (info->fIsLong)
+            *(double*)(args[0].ptrValue) = num;
+        else if (info->fIsLongDouble)
+            *(long double*)(args[0].ptrValue) = num;
+        else
+            *(float*)(args[0].ptrValue) = (float)num;
+    }
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLong_double)
+    num &= DBL_MAX;*/
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += parsePos;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos + skipped;
+}
+
+static int32_t
+u_scanf_scientific_handler(UFILE        *input,
+                           u_scanf_spec_info *info,
+                           ufmt_args    *args,
+                           const UChar  *fmt,
+                           int32_t      *fmtConsumed,
+                           int32_t      *argConverted)
+{
+    int32_t         len;
+    double          num;
+    UNumberFormat   *format;
+    int32_t         parsePos    = 0;
+    int32_t         skipped;
+    UErrorCode      status      = U_ZERO_ERROR;
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SCIENTIFIC);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
+
+    /* parse the number */
+    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
+
+    if (!info->fSkipArg) {
+        if (info->fIsLong)
+            *(double*)(args[0].ptrValue) = num;
+        else if (info->fIsLongDouble)
+            *(long double*)(args[0].ptrValue) = num;
+        else
+            *(float*)(args[0].ptrValue) = (float)num;
+    }
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLong_double)
+    num &= DBL_MAX;*/
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += parsePos;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos + skipped;
+}
+
+static int32_t
+u_scanf_scidbl_handler(UFILE        *input,
+                       u_scanf_spec_info *info,
+                       ufmt_args    *args,
+                       const UChar  *fmt,
+                       int32_t      *fmtConsumed,
+                       int32_t      *argConverted)
+{
+    int32_t       len;
+    double        num;
+    UNumberFormat *scientificFormat, *genericFormat;
+    /*int32_t       scientificResult, genericResult;*/
+    double        scientificResult, genericResult;
+    int32_t       scientificParsePos = 0, genericParsePos = 0, parsePos = 0;
+    int32_t       skipped;
+    UErrorCode    scientificStatus = U_ZERO_ERROR;
+    UErrorCode    genericStatus = U_ZERO_ERROR;
+
+
+    /* since we can't determine by scanning the characters whether */
+    /* a number was formatted in the 'f' or 'g' styles, parse the */
+    /* string with both formatters, and assume whichever one */
+    /* parsed the most is the correct formatter to use */
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatters */
+    scientificFormat = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SCIENTIFIC);
+    genericFormat = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(scientificFormat == 0 || genericFormat == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    skipped += u_scanf_skip_leading_positive_sign(input, genericFormat, &genericStatus);
+
+    /* parse the number using each format*/
+
+    scientificResult = unum_parseDouble(scientificFormat, input->str.fPos, len,
+        &scientificParsePos, &scientificStatus);
+
+    genericResult = unum_parseDouble(genericFormat, input->str.fPos, len,
+        &genericParsePos, &genericStatus);
+
+    /* determine which parse made it farther */
+    if(scientificParsePos > genericParsePos) {
+        /* stash the result in num */
+        num = scientificResult;
+        /* update the input's position to reflect consumed data */
+        parsePos += scientificParsePos;
+    }
+    else {
+        /* stash the result in num */
+        num = genericResult;
+        /* update the input's position to reflect consumed data */
+        parsePos += genericParsePos;
+    }
+    input->str.fPos += parsePos;
+
+    if (!info->fSkipArg) {
+        if (info->fIsLong)
+            *(double*)(args[0].ptrValue) = num;
+        else if (info->fIsLongDouble)
+            *(long double*)(args[0].ptrValue) = num;
+        else
+            *(float*)(args[0].ptrValue) = (float)num;
+    }
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLong_double)
+    num &= DBL_MAX;*/
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos + skipped;
+}
+
+static int32_t
+u_scanf_integer_handler(UFILE       *input,
+                        u_scanf_spec_info *info,
+                        ufmt_args   *args,
+                        const UChar *fmt,
+                        int32_t     *fmtConsumed,
+                        int32_t     *argConverted)
+{
+    int32_t         len;
+    void            *num        = (void*) (args[0].ptrValue);
+    UNumberFormat   *format;
+    int32_t         parsePos    = 0;
+    int32_t         skipped;
+    UErrorCode      status      = U_ZERO_ERROR;
+    int64_t         result;
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_DECIMAL);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
+
+    /* parse the number */
+    result = unum_parseInt64(format, input->str.fPos, len, &parsePos, &status);
+
+    /* mask off any necessary bits */
+    if (!info->fSkipArg) {
+        if (info->fIsShort)
+            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
+        else if (info->fIsLongLong)
+            *(int64_t*)num = result;
+        else
+            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
+    }
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += parsePos;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos + skipped;
+}
+
+static int32_t
+u_scanf_uinteger_handler(UFILE          *input,
+                         u_scanf_spec_info *info,
+                         ufmt_args      *args,
+                         const UChar    *fmt,
+                         int32_t        *fmtConsumed,
+                         int32_t        *argConverted)
+{
+    /* TODO Fix this when Numberformat handles uint64_t */
+    return u_scanf_integer_handler(input, info, args, fmt, fmtConsumed, argConverted);
+}
+
+static int32_t
+u_scanf_percent_handler(UFILE       *input,
+                        u_scanf_spec_info *info,
+                        ufmt_args   *args,
+                        const UChar *fmt,
+                        int32_t     *fmtConsumed,
+                        int32_t     *argConverted)
+{
+    int32_t         len;
+    double          num;
+    UNumberFormat   *format;
+    int32_t         parsePos    = 0;
+    int32_t         skipped;
+    UErrorCode      status      = U_ZERO_ERROR;
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_PERCENT);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    skipped += u_scanf_skip_leading_positive_sign(input, format, &status);
+
+    /* parse the number */
+    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
+
+    if (!info->fSkipArg) {
+        *(double*)(args[0].ptrValue) = num;
+    }
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLong_double)
+    num &= DBL_MAX;*/
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += parsePos;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos;
+}
+
+static int32_t
+u_scanf_string_handler(UFILE        *input,
+                       u_scanf_spec_info *info,
+                       ufmt_args    *args,
+                       const UChar  *fmt,
+                       int32_t      *fmtConsumed,
+                       int32_t      *argConverted)
+{
+    const UChar *source;
+    UConverter  *conv;
+    char        *arg    = (char*)(args[0].ptrValue);
+    char        *alias  = arg;
+    char        *limit;
+    UErrorCode  status  = U_ZERO_ERROR;
+    int32_t     count;
+    int32_t     skipped = 0;
+    UChar       c;
+    UBool       isNotEOF = FALSE;
+
+    /* skip all ws in the input */
+    if (info->fIsString) {
+        skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+    }
+
+    /* get the string one character at a time, truncating to the width */
+    count = 0;
+
+    /* open the default converter */
+    conv = u_getDefaultConverter(&status);
+
+    if(U_FAILURE(status))
+        return -1;
+
+    while( (info->fWidth == -1 || count < info->fWidth) 
+        && (isNotEOF = ufile_getch(input, &c))
+        && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
+    {
+
+        if (!info->fSkipArg) {
+            /* put the character from the input onto the target */
+            source = &c;
+            /* Since we do this one character at a time, do it this way. */
+            if (info->fWidth > 0) {
+                limit = alias + info->fWidth - count;
+            }
+            else {
+                limit = alias + ucnv_getMaxCharSize(conv);
+            }
+
+            /* convert the character to the default codepage */
+            ucnv_fromUnicode(conv, &alias, limit, &source, source + 1,
+                NULL, TRUE, &status);
+
+            if(U_FAILURE(status)) {
+                /* clean up */
+                u_releaseDefaultConverter(conv);
+                return -1;
+            }
+        }
+
+        /* increment the count */
+        ++count;
+    }
+
+    /* put the final character we read back on the input */
+    if (!info->fSkipArg) {
+        if ((info->fWidth == -1 || count < info->fWidth) && isNotEOF)
+            u_fungetc(c, input);
+
+        /* add the terminator */
+        if (info->fIsString) {
+            *alias = 0x00;
+        }
+    }
+
+    /* clean up */
+    u_releaseDefaultConverter(conv);
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return count + skipped;
+}
+
+static int32_t
+u_scanf_char_handler(UFILE          *input,
+                     u_scanf_spec_info *info,
+                     ufmt_args      *args,
+                     const UChar    *fmt,
+                     int32_t        *fmtConsumed,
+                     int32_t        *argConverted)
+{
+    if (info->fWidth < 0) {
+        info->fWidth = 1;
+    }
+    info->fIsString = FALSE;
+    return u_scanf_string_handler(input, info, args, fmt, fmtConsumed, argConverted);
+}
+
+static int32_t
+u_scanf_ustring_handler(UFILE       *input,
+                        u_scanf_spec_info *info,
+                        ufmt_args   *args,
+                        const UChar *fmt,
+                        int32_t     *fmtConsumed,
+                        int32_t     *argConverted)
+{
+    UChar   *arg     = (UChar*)(args[0].ptrValue);
+    UChar   *alias     = arg;
+    int32_t count;
+    int32_t skipped = 0;
+    UChar   c;
+    UBool   isNotEOF = FALSE;
+
+    /* skip all ws in the input */
+    if (info->fIsString) {
+        skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+    }
+
+    /* get the string one character at a time, truncating to the width */
+    count = 0;
+
+    while( (info->fWidth == -1 || count < info->fWidth)
+        && (isNotEOF = ufile_getch(input, &c))
+        && (!info->fIsString || (c != info->fPadChar && !u_isWhitespace(c))))
+    {
+
+        /* put the character from the input onto the target */
+        if (!info->fSkipArg) {
+            *alias++ = c;
+        }
+
+        /* increment the count */
+        ++count;
+    }
+
+    /* put the final character we read back on the input */
+    if (!info->fSkipArg) {
+        if((info->fWidth == -1 || count < info->fWidth) && isNotEOF) {
+            u_fungetc(c, input);
+        }
+
+        /* add the terminator */
+        if (info->fIsString) {
+            *alias = 0x0000;
+        }
+    }
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return count + skipped;
+}
+
+static int32_t
+u_scanf_uchar_handler(UFILE         *input,
+                      u_scanf_spec_info *info,
+                      ufmt_args     *args,
+                      const UChar   *fmt,
+                      int32_t       *fmtConsumed,
+                      int32_t       *argConverted)
+{
+    if (info->fWidth < 0) {
+        info->fWidth = 1;
+    }
+    info->fIsString = FALSE;
+    return u_scanf_ustring_handler(input, info, args, fmt, fmtConsumed, argConverted);
+}
+
+static int32_t
+u_scanf_spellout_handler(UFILE          *input,
+                         u_scanf_spec_info *info,
+                         ufmt_args      *args,
+                         const UChar    *fmt,
+                         int32_t        *fmtConsumed,
+                         int32_t        *argConverted)
+{
+    int32_t         len;
+    double          num;
+    UNumberFormat   *format;
+    int32_t         parsePos    = 0;
+    int32_t         skipped;
+    UErrorCode      status      = U_ZERO_ERROR;
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* get the formatter */
+    format = u_locbund_getNumberFormat(&input->str.fBundle, UNUM_SPELLOUT);
+
+    /* handle error */
+    if(format == 0)
+        return 0;
+
+    /* Skip the positive prefix. ICU normally can't handle this due to strict parsing. */
+    /* This is not applicable to RBNF. */
+    /*skipped += u_scanf_skip_leading_positive_sign(input, format, &status);*/
+
+    /* parse the number */
+    num = unum_parseDouble(format, input->str.fPos, len, &parsePos, &status);
+
+    if (!info->fSkipArg) {
+        *(double*)(args[0].ptrValue) = num;
+    }
+
+    /* mask off any necessary bits */
+    /*  if(! info->fIsLong_double)
+    num &= DBL_MAX;*/
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += parsePos;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return parsePos + skipped;
+}
+
+static int32_t
+u_scanf_hex_handler(UFILE       *input,
+                    u_scanf_spec_info *info,
+                    ufmt_args   *args,
+                    const UChar *fmt,
+                    int32_t     *fmtConsumed,
+                    int32_t     *argConverted)
+{
+    int32_t     len;
+    int32_t     skipped;
+    void        *num    = (void*) (args[0].ptrValue);
+    int64_t     result;
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* check for alternate form */
+    if( *(input->str.fPos) == 0x0030 &&
+        (*(input->str.fPos + 1) == 0x0078 || *(input->str.fPos + 1) == 0x0058) ) {
+
+        /* skip the '0' and 'x' or 'X' if present */
+        input->str.fPos += 2;
+        len -= 2;
+    }
+
+    /* parse the number */
+    result = ufmt_uto64(input->str.fPos, &len, 16);
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += len;
+
+    /* mask off any necessary bits */
+    if (!info->fSkipArg) {
+        if (info->fIsShort)
+            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
+        else if (info->fIsLongLong)
+            *(int64_t*)num = result;
+        else
+            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
+    }
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return len + skipped;
+}
+
+static int32_t
+u_scanf_octal_handler(UFILE         *input,
+                      u_scanf_spec_info *info,
+                      ufmt_args     *args,
+                      const UChar   *fmt,
+                      int32_t       *fmtConsumed,
+                      int32_t       *argConverted)
+{
+    int32_t     len;
+    int32_t     skipped;
+    void        *num         = (void*) (args[0].ptrValue);
+    int64_t     result;
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1)
+        len = ufmt_min(len, info->fWidth);
+
+    /* parse the number */
+    result = ufmt_uto64(input->str.fPos, &len, 8);
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += len;
+
+    /* mask off any necessary bits */
+    if (!info->fSkipArg) {
+        if (info->fIsShort)
+            *(int16_t*)num = (int16_t)(UINT16_MAX & result);
+        else if (info->fIsLongLong)
+            *(int64_t*)num = result;
+        else
+            *(int32_t*)num = (int32_t)(UINT32_MAX & result);
+    }
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return len + skipped;
+}
+
+static int32_t
+u_scanf_pointer_handler(UFILE       *input,
+                        u_scanf_spec_info *info,
+                        ufmt_args   *args,
+                        const UChar *fmt,
+                        int32_t     *fmtConsumed,
+                        int32_t     *argConverted)
+{
+    int32_t len;
+    int32_t skipped;
+    void    *result;
+    void    **p     = (void**)(args[0].ptrValue);
+
+
+    /* skip all ws in the input */
+    skipped = u_scanf_skip_leading_ws(input, info->fPadChar);
+
+    /* fill the input's internal buffer */
+    ufile_fill_uchar_buffer(input);
+
+    /* determine the size of the input's buffer */
+    len = (int32_t)(input->str.fLimit - input->str.fPos);
+
+    /* truncate to the width, if specified */
+    if(info->fWidth != -1) {
+        len = ufmt_min(len, info->fWidth);
+    }
+
+    /* Make sure that we don't consume too much */
+    if (len > (int32_t)(sizeof(void*)*2)) {
+        len = (int32_t)(sizeof(void*)*2);
+    }
+
+    /* parse the pointer - assign to temporary value */
+    result = ufmt_utop(input->str.fPos, &len);
+
+    if (!info->fSkipArg) {
+        *p = result;
+    }
+
+    /* update the input's position to reflect consumed data */
+    input->str.fPos += len;
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return len + skipped;
+}
+
+static int32_t
+u_scanf_scanset_handler(UFILE       *input,
+                        u_scanf_spec_info *info,
+                        ufmt_args   *args,
+                        const UChar *fmt,
+                        int32_t     *fmtConsumed,
+                        int32_t     *argConverted)
+{
+    USet        *scanset;
+    UErrorCode  status = U_ZERO_ERROR;
+    int32_t     chLeft = INT32_MAX;
+    UChar32     c;
+    UChar       *alias = (UChar*) (args[0].ptrValue);
+    UBool       isNotEOF = FALSE;
+    UBool       readCharacter = FALSE;
+
+    /* Create an empty set */
+    scanset = uset_open(0, -1);
+
+    /* Back up one to get the [ */
+    fmt--;
+
+    /* truncate to the width, if specified and alias the target */
+    if(info->fWidth >= 0) {
+        chLeft = info->fWidth;
+    }
+
+    /* parse the scanset from the fmt string */
+    *fmtConsumed = uset_applyPattern(scanset, fmt, -1, 0, &status);
+
+    /* verify that the parse was successful */
+    if (U_SUCCESS(status)) {
+        c=0;
+
+        /* grab characters one at a time and make sure they are in the scanset */
+        while(chLeft > 0) {
+            if ((isNotEOF = ufile_getch32(input, &c)) && uset_contains(scanset, c)) {
+                readCharacter = TRUE;
+                if (!info->fSkipArg) {
+                    int32_t idx = 0;
+                    UBool isError = FALSE;
+
+                    U16_APPEND(alias, idx, chLeft, c, isError);
+                    if (isError) {
+                        break;
+                    }
+                    alias += idx;
+                }
+                chLeft -= (1 + U_IS_SUPPLEMENTARY(c));
+            }
+            else {
+                /* if the character's not in the scanset, break out */
+                break;
+            }
+        }
+
+        /* put the final character we read back on the input */
+        if(isNotEOF && chLeft > 0) {
+            u_fungetc(c, input);
+        }
+    }
+
+    uset_close(scanset);
+
+    /* if we didn't match at least 1 character, fail */
+    if(!readCharacter)
+        return -1;
+    /* otherwise, add the terminator */
+    else if (!info->fSkipArg) {
+        *alias = 0x00;
+    }
+
+    /* we converted 1 arg */
+    *argConverted = !info->fSkipArg;
+    return (info->fWidth >= 0 ? info->fWidth : INT32_MAX) - chLeft;
+}
+
+/* Use US-ASCII characters only for formatting. Most codepages have
+ characters 20-7F from Unicode. Using any other codepage specific
+ characters will make it very difficult to format the string on
+ non-Unicode machines */
+static const u_scanf_info g_u_scanf_infos[USCANF_NUM_FMT_HANDLERS] = {
+/* 0x20 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_SIMPLE_PERCENT,UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x30 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x40 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR,
+    UFMT_EMPTY,         UFMT_SCIENTIFIC,    UFMT_EMPTY,         UFMT_SCIDBL,
+#ifdef U_USE_OBSOLETE_IO_FORMATTING
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_UCHAR/*deprecated*/,
+#else
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+#endif
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x50 */
+    UFMT_PERCENT,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_USTRING,
+#ifdef U_USE_OBSOLETE_IO_FORMATTING
+    UFMT_EMPTY,         UFMT_USTRING/*deprecated*/,UFMT_SPELLOUT,      UFMT_EMPTY,
+#else
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SPELLOUT,      UFMT_EMPTY,
+#endif
+    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_SCANSET,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+
+/* 0x60 */
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_CHAR,
+    UFMT_INT,           UFMT_SCIENTIFIC,    UFMT_DOUBLE,        UFMT_SCIDBL,
+    UFMT_EMPTY,         UFMT_INT,           UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_COUNT,         UFMT_OCTAL,
+
+/* 0x70 */
+    UFMT_POINTER,       UFMT_EMPTY,         UFMT_EMPTY,         UFMT_STRING,
+    UFMT_EMPTY,         UFMT_UINT,          UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_HEX,           UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+    UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,         UFMT_EMPTY,
+};
+
+U_CFUNC int32_t
+u_scanf_parse(UFILE     *f,
+            const UChar *patternSpecification,
+            va_list     ap)
+{
+    const UChar     *alias;
+    int32_t         count, converted, argConsumed, cpConsumed;
+    uint16_t        handlerNum;
+
+    ufmt_args       args;
+    u_scanf_spec    spec;
+    ufmt_type_info  info;
+    u_scanf_handler handler;
+
+    /* alias the pattern */
+    alias = patternSpecification;
+
+    /* haven't converted anything yet */
+    argConsumed = 0;
+    converted = 0;
+    cpConsumed = 0;
+
+    /* iterate through the pattern */
+    for(;;) {
+
+        /* match any characters up to the next '%' */
+        while(*alias != UP_PERCENT && *alias != 0x0000 && u_fgetc(f) == *alias) {
+            alias++;
+        }
+
+        /* if we aren't at a '%', or if we're at end of string, break*/
+        if(*alias != UP_PERCENT || *alias == 0x0000)
+            break;
+
+        /* parse the specifier */
+        count = u_scanf_parse_spec(alias, &spec);
+
+        /* update the pointer in pattern */
+        alias += count;
+
+        handlerNum = (uint16_t)(spec.fInfo.fSpec - USCANF_BASE_FMT_HANDLERS);
+        if (handlerNum < USCANF_NUM_FMT_HANDLERS) {
+            /* skip the argument, if necessary */
+            /* query the info function for argument information */
+            info = g_u_scanf_infos[ handlerNum ].info;
+            if (info != ufmt_count && u_feof(f)) {
+                break;
+            }
+            else if(spec.fInfo.fSkipArg) {
+                args.ptrValue = NULL;
+            }
+            else {
+                switch(info) {
+                case ufmt_count:
+                    /* set the spec's width to the # of items converted */
+                    spec.fInfo.fWidth = cpConsumed;
+                    /* fall through to next case */
+                case ufmt_char:
+                case ufmt_uchar:
+                case ufmt_int:
+                case ufmt_string:
+                case ufmt_ustring:
+                case ufmt_pointer:
+                case ufmt_float:
+                case ufmt_double:
+                    args.ptrValue = va_arg(ap, void*);
+                    break;
+
+                default:
+                    /* else args is ignored */
+                    args.ptrValue = NULL;
+                    break;
+                }
+            }
+
+            /* call the handler function */
+            handler = g_u_scanf_infos[ handlerNum ].handler;
+            if(handler != 0) {
+
+                /* reset count to 1 so that += for alias works. */
+                count = 1;
+
+                cpConsumed += (*handler)(f, &spec.fInfo, &args, alias, &count, &argConsumed);
+
+                /* if the handler encountered an error condition, break */
+                if(argConsumed < 0) {
+                    converted = -1;
+                    break;
+                }
+
+                /* add to the # of items converted */
+                converted += argConsumed;
+
+                /* update the pointer in pattern */
+                alias += count-1;
+            }
+            /* else do nothing */
+        }
+        /* else do nothing */
+
+        /* just ignore unknown tags */
+    }
+
+    /* return # of items converted */
+    return converted;
+}
+
+#endif /* #if !UCONFIG_NO_FORMATTING */


Property changes on: trunk/source/io/uscanf_p.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ustdio.c
===================================================================
--- trunk/source/io/ustdio.c	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ustdio.c	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,703 +1,703 @@
-/*
-******************************************************************************
-*
-*   Copyright (C) 1998-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-*
-******************************************************************************
-*
-* File ustdio.c
-*
-* Modification History:
-*
-*   Date        Name        Description
-*   11/18/98    stephen     Creation.
-*   03/12/99    stephen     Modified for new C API.
-*   07/19/99    stephen     Fixed read() and gets()
-******************************************************************************
-*/
-
-#include "unicode/ustdio.h"
-#include "unicode/putil.h"
-#include "cmemory.h"
-#include "cstring.h"
-#include "ufile.h"
-#include "ufmt_cmn.h"
-#include "unicode/ucnv.h"
-#include "unicode/ustring.h"
-
-#include <string.h>
-
-#define DELIM_LF 0x000A
-#define DELIM_VT 0x000B
-#define DELIM_FF 0x000C
-#define DELIM_CR 0x000D
-#define DELIM_NEL 0x0085
-#define DELIM_LS 0x2028
-#define DELIM_PS 0x2029
-
-/* TODO: is this correct for all codepages? Should we just use \n and let the converter handle it? */
-#ifdef U_WINDOWS
-static const UChar DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 };
-static const uint32_t DELIMITERS_LEN = 2;
-/* TODO: Default newline writing should be detected based upon the converter being used. */
-#else
-static const UChar DELIMITERS [] = { DELIM_LF, 0x0000 };
-static const uint32_t DELIMITERS_LEN = 1;
-#endif
-
-#define IS_FIRST_STRING_DELIMITER(c1) \
- (UBool)((DELIM_LF <= (c1) && (c1) <= DELIM_CR) \
-        || (c1) == DELIM_NEL \
-        || (c1) == DELIM_LS \
-        || (c1) == DELIM_PS)
-#define CAN_HAVE_COMBINED_STRING_DELIMITER(c1) (UBool)((c1) == DELIM_CR)
-#define IS_COMBINED_STRING_DELIMITER(c1, c2) \
- (UBool)((c1) == DELIM_CR && (c2) == DELIM_LF)
-
-
-#if !UCONFIG_NO_TRANSLITERATION
-
-U_CAPI UTransliterator* U_EXPORT2
-u_fsettransliterator(UFILE *file, UFileDirection direction,
-                     UTransliterator *adopt, UErrorCode *status)
-{
-    UTransliterator *old = NULL;
-
-    if(U_FAILURE(*status))
-    {
-        return adopt;
-    }
-
-    if(!file)
-    {
-        *status = U_ILLEGAL_ARGUMENT_ERROR;
-        return adopt;
-    }
-
-    if(direction & U_READ)
-    {
-        /** TODO: implement */
-        *status = U_UNSUPPORTED_ERROR;
-        return adopt;
-    }
-
-    if(adopt == NULL) /* they are clearing it */
-    {
-        if(file->fTranslit != NULL)
-        {
-            /* TODO: Check side */
-            old = file->fTranslit->translit;
-            uprv_free(file->fTranslit->buffer);
-            file->fTranslit->buffer=NULL;
-            uprv_free(file->fTranslit);
-            file->fTranslit=NULL;
-        }
-    }
-    else
-    {
-        if(file->fTranslit == NULL)
-        {
-            file->fTranslit = (UFILETranslitBuffer*) uprv_malloc(sizeof(UFILETranslitBuffer));
-            if(!file->fTranslit)
-            {
-                *status = U_MEMORY_ALLOCATION_ERROR;
-                return adopt;
-            }
-            file->fTranslit->capacity = 0;
-            file->fTranslit->length = 0;
-            file->fTranslit->pos = 0;
-            file->fTranslit->buffer = NULL;
-        }
-        else
-        {
-            old = file->fTranslit->translit;
-            ufile_flush_translit(file);
-        }
-
-        file->fTranslit->translit = adopt;
-    }
-
-    return old;
-}
-
-static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, UBool flush)
-{
-    int32_t newlen;
-    int32_t junkCount = 0;
-    int32_t textLength;
-    int32_t textLimit;
-    UTransPosition pos;
-    UErrorCode status = U_ZERO_ERROR;
-
-    if(count == NULL)
-    {
-        count = &junkCount;
-    }
-
-    if ((!f)||(!f->fTranslit)||(!f->fTranslit->translit))
-    {
-        /* fast path */
-        return src;
-    }
-
-    /* First: slide over everything */
-    if(f->fTranslit->length > f->fTranslit->pos)
-    {
-        memmove(f->fTranslit->buffer, f->fTranslit->buffer + f->fTranslit->pos,
-            (f->fTranslit->length - f->fTranslit->pos)*sizeof(UChar));
-    }
-    f->fTranslit->length -= f->fTranslit->pos; /* always */
-    f->fTranslit->pos = 0;
-
-    /* Calculate new buffer size needed */
-    newlen = (*count + f->fTranslit->length) * 4;
-
-    if(newlen > f->fTranslit->capacity)
-    {
-        if(f->fTranslit->buffer == NULL)
-        {
-            f->fTranslit->buffer = (UChar*)uprv_malloc(newlen * sizeof(UChar));
-        }
-        else
-        {
-            f->fTranslit->buffer = (UChar*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(UChar));
-        }
-        f->fTranslit->capacity = newlen;
-    }
-
-    /* Now, copy any data over */
-    u_strncpy(f->fTranslit->buffer + f->fTranslit->length,
-        src,
-        *count);
-    f->fTranslit->length += *count;
-
-    /* Now, translit in place as much as we can  */
-    if(flush == FALSE)
-    {
-        textLength = f->fTranslit->length;
-        pos.contextStart = 0;
-        pos.contextLimit = textLength;
-        pos.start        = 0;
-        pos.limit        = textLength;
-
-        utrans_transIncrementalUChars(f->fTranslit->translit,
-            f->fTranslit->buffer, /* because we shifted */
-            &textLength,
-            f->fTranslit->capacity,
-            &pos,
-            &status);
-
-        /* now: start/limit point to the transliterated text */
-        /* Transliterated is [buffer..pos.start) */
-        *count            = pos.start;
-        f->fTranslit->pos = pos.start;
-        f->fTranslit->length = pos.limit;
-
-        return f->fTranslit->buffer;
-    }
-    else
-    {
-        textLength = f->fTranslit->length;
-        textLimit = f->fTranslit->length;
-
-        utrans_transUChars(f->fTranslit->translit,
-            f->fTranslit->buffer,
-            &textLength,
-            f->fTranslit->capacity,
-            0,
-            &textLimit,
-            &status);
-
-        /* out: converted len */
-        *count = textLimit;
-
-        /* Set pointers to 0 */
-        f->fTranslit->pos = 0;
-        f->fTranslit->length = 0;
-
-        return f->fTranslit->buffer;
-    }
-}
-
-#endif
-
-void
-ufile_flush_translit(UFILE *f)
-{
-#if !UCONFIG_NO_TRANSLITERATION
-    if((!f)||(!f->fTranslit))
-        return;
-#endif
-
-    u_file_write_flush(NULL, 0, f, FALSE, TRUE);
-}
-
-
-void
-ufile_close_translit(UFILE *f)
-{
-#if !UCONFIG_NO_TRANSLITERATION
-    if((!f)||(!f->fTranslit))
-        return;
-#endif
-
-    ufile_flush_translit(f);
-
-#if !UCONFIG_NO_TRANSLITERATION
-    if(f->fTranslit->translit)
-        utrans_close(f->fTranslit->translit);
-
-    if(f->fTranslit->buffer)
-    {
-        uprv_free(f->fTranslit->buffer);
-    }
-
-    uprv_free(f->fTranslit);
-    f->fTranslit = NULL;
-#endif
-}
-
-
-/* Input/output */
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fputs(const UChar    *s,
-        UFILE        *f)
-{
-    int32_t count = u_file_write(s, u_strlen(s), f);
-    count += u_file_write(DELIMITERS, DELIMITERS_LEN, f);
-    return count;
-}
-
-U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fputc(UChar32      uc,
-        UFILE        *f)
-{
-    UChar buf[2];
-    int32_t idx = 0;
-    UBool isError = FALSE;
-
-    U16_APPEND(buf, idx, sizeof(buf)/sizeof(*buf), uc, isError);
-    if (isError) {
-        return U_EOF;
-    }
-    return u_file_write(buf, idx, f) == idx ? uc : U_EOF;
-}
-
-
-U_CAPI int32_t U_EXPORT2
-u_file_write_flush(const UChar *chars,
-                   int32_t     count,
-                   UFILE       *f,
-                   UBool       flushIO,
-                   UBool       flushTranslit)
-{
-    /* Set up conversion parameters */
-    UErrorCode  status       = U_ZERO_ERROR;
-    const UChar *mySource    = chars;
-    const UChar *mySourceEnd;
-    char        charBuffer[UFILE_CHARBUFFER_SIZE];
-    char        *myTarget   = charBuffer;
-    int32_t     written      = 0;
-    int32_t     numConverted = 0;
-
-    if (count < 0) {
-        count = u_strlen(chars);
-    }
-
-#if !UCONFIG_NO_TRANSLITERATION
-    if((f->fTranslit) && (f->fTranslit->translit))
-    {
-        /* Do the transliteration */
-        mySource = u_file_translit(f, chars, &count, flushTranslit);
-    }
-#endif
-
-    /* Write to a string. */
-    if (!f->fFile) {
-        int32_t charsLeft = (int32_t)(f->str.fLimit - f->str.fPos);
-        if (flushIO && charsLeft > count) {
-            count++;
-        }
-        written = ufmt_min(count, charsLeft);
-        u_strncpy(f->str.fPos, mySource, written);
-        f->str.fPos += written;
-        return written;
-    }
-
-    mySourceEnd = mySource + count;
-
-    /* Perform the conversion in a loop */
-    do {
-        status     = U_ZERO_ERROR;
-        if(f->fConverter != NULL) { /* We have a valid converter */
-            ucnv_fromUnicode(f->fConverter,
-                &myTarget,
-                charBuffer + UFILE_CHARBUFFER_SIZE,
-                &mySource,
-                mySourceEnd,
-                NULL,
-                flushIO,
-                &status);
-        } else { /*weiv: do the invariant conversion */
-            u_UCharsToChars(mySource, myTarget, count);
-            myTarget += count;
-        }
-        numConverted = (int32_t)(myTarget - charBuffer);
-
-        if (numConverted > 0) {
-            /* write the converted bytes */
-            fwrite(charBuffer,
-                sizeof(char),
-                numConverted,
-                f->fFile);
-
-            written     += numConverted;
-        }
-        myTarget     = charBuffer;
-    }
-    while(status == U_BUFFER_OVERFLOW_ERROR);
-
-    /* return # of chars written */
-    return written;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_file_write(    const UChar     *chars,
-             int32_t        count,
-             UFILE         *f)
-{
-    return u_file_write_flush(chars,count,f,FALSE,FALSE);
-}
-
-
-/* private function used for buffering input */
-void
-ufile_fill_uchar_buffer(UFILE *f)
-{
-    UErrorCode  status;
-    const char  *mySource;
-    const char  *mySourceEnd;
-    UChar       *myTarget;
-    int32_t     bufferSize;
-    int32_t     maxCPBytes;
-    int32_t     bytesRead;
-    int32_t     availLength;
-    int32_t     dataSize;
-    char        charBuffer[UFILE_CHARBUFFER_SIZE];
-    u_localized_string *str;
-
-    if (f->fFile == NULL) {
-        /* There is nothing to do. It's a string. */
-        return;
-    }
-
-    str = &f->str;
-    dataSize = (int32_t)(str->fLimit - str->fPos);
-    if (f->fFileno == 0 && dataSize > 0) {
-        /* Don't read from stdin too many times. There is still some data. */
-        return;
-    }
-
-    /* shift the buffer if it isn't empty */
-    if(dataSize != 0) {
-        uprv_memmove(f->fUCBuffer, str->fPos, dataSize * sizeof(UChar));
-    }
-
-
-    /* record how much buffer space is available */
-    availLength = UFILE_UCHARBUFFER_SIZE - dataSize;
-
-    /* Determine the # of codepage bytes needed to fill our UChar buffer */
-    /* weiv: if converter is NULL, we use invariant converter with charwidth = 1)*/
-    maxCPBytes = availLength / (f->fConverter!=NULL?(2*ucnv_getMinCharSize(f->fConverter)):1);
-
-    /* Read in the data to convert */
-    if (f->fFileno == 0) {
-        /* Special case. Read from stdin one line at a time. */
-        char *retStr = fgets(charBuffer, ufmt_min(maxCPBytes, UFILE_CHARBUFFER_SIZE), f->fFile);
-        bytesRead = (int32_t)(retStr ? uprv_strlen(charBuffer) : 0);
-    }
-    else {
-        /* A normal file */
-        bytesRead = (int32_t)fread(charBuffer,
-            sizeof(char),
-            ufmt_min(maxCPBytes, UFILE_CHARBUFFER_SIZE),
-            f->fFile);
-    }
-
-    /* Set up conversion parameters */
-    status      = U_ZERO_ERROR;
-    mySource    = charBuffer;
-    mySourceEnd = charBuffer + bytesRead;
-    myTarget    = f->fUCBuffer + dataSize;
-    bufferSize  = UFILE_UCHARBUFFER_SIZE;
-
-    if(f->fConverter != NULL) { /* We have a valid converter */
-        /* Perform the conversion */
-        ucnv_toUnicode(f->fConverter,
-            &myTarget,
-            f->fUCBuffer + bufferSize,
-            &mySource,
-            mySourceEnd,
-            NULL,
-            (UBool)(feof(f->fFile) != 0),
-            &status);
-
-    } else { /*weiv: do the invariant conversion */
-        u_charsToUChars(mySource, myTarget, bytesRead);
-        myTarget += bytesRead;
-    }
-
-    /* update the pointers into our array */
-    str->fPos    = str->fBuffer;
-    str->fLimit  = myTarget;
-}
-
-U_CAPI UChar* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgets(UChar        *s,
-        int32_t       n,
-        UFILE        *f)
-{
-    int32_t dataSize;
-    int32_t count;
-    UChar *alias;
-    const UChar *limit;
-    UChar *sItr;
-    UChar currDelim = 0;
-    u_localized_string *str;
-
-    if (n <= 0) {
-        /* Caller screwed up. We need to write the null terminatior. */
-        return NULL;
-    }
-
-    /* fill the buffer if needed */
-    str = &f->str;
-    if (str->fPos >= str->fLimit) {
-        ufile_fill_uchar_buffer(f);
-    }
-
-    /* subtract 1 from n to compensate for the terminator */
-    --n;
-
-    /* determine the amount of data in the buffer */
-    dataSize = (int32_t)(str->fLimit - str->fPos);
-
-    /* if 0 characters were left, return 0 */
-    if (dataSize == 0)
-        return NULL;
-
-    /* otherwise, iteratively fill the buffer and copy */
-    count = 0;
-    sItr = s;
-    currDelim = 0;
-    while (dataSize > 0 && count < n) {
-        alias = str->fPos;
-
-        /* Find how much to copy */
-        if (dataSize < (n - count)) {
-            limit = str->fLimit;
-        }
-        else {
-            limit = alias + (n - count);
-        }
-
-        if (!currDelim) {
-            /* Copy UChars until we find the first occurrence of a delimiter character */
-            while (alias < limit && !IS_FIRST_STRING_DELIMITER(*alias)) {
-                count++;
-                *(sItr++) = *(alias++);
-            }
-            /* Preserve the newline */
-            if (alias < limit && IS_FIRST_STRING_DELIMITER(*alias)) {
-                if (CAN_HAVE_COMBINED_STRING_DELIMITER(*alias)) {
-                    currDelim = *alias;
-                }
-                else {
-                    currDelim = 1;  /* This isn't a newline, but it's used to say
-                                    that we should break later. We've checked all
-                                    possible newline combinations even across buffer
-                                    boundaries. */
-                }
-                count++;
-                *(sItr++) = *(alias++);
-            }
-        }
-        /* If we have a CRLF combination, preserve that too. */
-        if (alias < limit) {
-            if (currDelim && IS_COMBINED_STRING_DELIMITER(currDelim, *alias)) {
-                count++;
-                *(sItr++) = *(alias++);
-            }
-            currDelim = 1;  /* This isn't a newline, but it's used to say
-                            that we should break later. We've checked all
-                            possible newline combinations even across buffer
-                            boundaries. */
-        }
-
-        /* update the current buffer position */
-        str->fPos = alias;
-
-        /* if we found a delimiter */
-        if (currDelim == 1) {
-            /* break out */
-            break;
-        }
-
-        /* refill the buffer */
-        ufile_fill_uchar_buffer(f);
-
-        /* determine the amount of data in the buffer */
-        dataSize = (int32_t)(str->fLimit - str->fPos);
-    }
-
-    /* add the terminator and return s */
-    *sItr = 0x0000;
-    return s;
-}
-
-U_CFUNC UBool U_EXPORT2
-ufile_getch(UFILE *f, UChar *ch)
-{
-    UBool isValidChar = FALSE;
-
-    *ch = U_EOF;
-    /* if we have an available character in the buffer, return it */
-    if(f->str.fPos < f->str.fLimit){
-        *ch = *(f->str.fPos)++;
-        isValidChar = TRUE;
-    }
-    else if (f) {
-        /* otherwise, fill the buffer and return the next character */
-        if(f->str.fPos >= f->str.fLimit) {
-            ufile_fill_uchar_buffer(f);
-        }
-        if(f->str.fPos < f->str.fLimit) {
-            *ch = *(f->str.fPos)++;
-            isValidChar = TRUE;
-        }
-    }
-    return isValidChar;
-}
-
-U_CAPI UChar U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetc(UFILE        *f)
-{
-    UChar ch;
-    ufile_getch(f, &ch);
-    return ch;
-}
-
-U_CFUNC UBool U_EXPORT2
-ufile_getch32(UFILE *f, UChar32 *c32)
-{
-    UBool isValidChar = FALSE;
-    u_localized_string *str;
-
-    *c32 = U_EOF;
-
-    /* Fill the buffer if it is empty */
-    str = &f->str;
-    if (f && str->fPos + 1 >= str->fLimit) {
-        ufile_fill_uchar_buffer(f);
-    }
-
-    /* Get the next character in the buffer */
-    if (str->fPos < str->fLimit) {
-        *c32 = *(str->fPos)++;
-        if (U_IS_LEAD(*c32)) {
-            if (str->fPos < str->fLimit) {
-                UChar c16 = *(str->fPos)++;
-                *c32 = U16_GET_SUPPLEMENTARY(*c32, c16);
-                isValidChar = TRUE;
-            }
-            else {
-                *c32 = U_EOF;
-            }
-        }
-        else {
-            isValidChar = TRUE;
-        }
-    }
-
-    return isValidChar;
-}
-
-U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fgetcx(UFILE        *f)
-{
-    UChar32 ch;
-    ufile_getch32(f, &ch);
-    return ch;
-}
-
-U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_fungetc(UChar32        ch,
-    UFILE        *f)
-{
-    u_localized_string *str;
-
-    str = &f->str;
-
-    /* if we're at the beginning of the buffer, sorry! */
-    if (str->fPos == str->fBuffer
-        || (U_IS_LEAD(ch) && (str->fPos - 1) == str->fBuffer))
-    {
-        ch = U_EOF;
-    }
-    else {
-        /* otherwise, put the character back */
-        /* Remember, read them back on in the reverse order. */
-        if (U_IS_LEAD(ch)) {
-            if (*--(str->fPos) != U16_TRAIL(ch)
-                || *--(str->fPos) != U16_LEAD(ch))
-            {
-                ch = U_EOF;
-            }
-        }
-        else if (*--(str->fPos) != ch) {
-            ch = U_EOF;
-        }
-    }
-    return ch;
-}
-
-U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
-u_file_read(    UChar        *chars,
-    int32_t        count,
-    UFILE         *f)
-{
-    int32_t dataSize;
-    int32_t read = 0;
-    u_localized_string *str = &f->str;
-
-    do {
-
-        /* determine the amount of data in the buffer */
-        dataSize = (int32_t)(str->fLimit - str->fPos);
-        if (dataSize <= 0) {
-            /* fill the buffer */
-            ufile_fill_uchar_buffer(f);
-            dataSize = (int32_t)(str->fLimit - str->fPos);
-        }
-
-        /* Make sure that we don't read too much */
-        if (dataSize > (count - read)) {
-            dataSize = count - read;
-        }
-
-        /* copy the current data in the buffer */
-        memcpy(chars + read, str->fPos, dataSize * sizeof(UChar));
-
-        /* update number of items read */
-        read += dataSize;
-
-        /* update the current buffer position */
-        str->fPos += dataSize;
-    }
-    while (dataSize != 0 && read < count);
-
-    return read;
-}
+/*
+******************************************************************************
+*
+*   Copyright (C) 1998-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+*
+******************************************************************************
+*
+* File ustdio.c
+*
+* Modification History:
+*
+*   Date        Name        Description
+*   11/18/98    stephen     Creation.
+*   03/12/99    stephen     Modified for new C API.
+*   07/19/99    stephen     Fixed read() and gets()
+******************************************************************************
+*/
+
+#include "unicode/ustdio.h"
+#include "unicode/putil.h"
+#include "cmemory.h"
+#include "cstring.h"
+#include "ufile.h"
+#include "ufmt_cmn.h"
+#include "unicode/ucnv.h"
+#include "unicode/ustring.h"
+
+#include <string.h>
+
+#define DELIM_LF 0x000A
+#define DELIM_VT 0x000B
+#define DELIM_FF 0x000C
+#define DELIM_CR 0x000D
+#define DELIM_NEL 0x0085
+#define DELIM_LS 0x2028
+#define DELIM_PS 0x2029
+
+/* TODO: is this correct for all codepages? Should we just use \n and let the converter handle it? */
+#ifdef U_WINDOWS
+static const UChar DELIMITERS [] = { DELIM_CR, DELIM_LF, 0x0000 };
+static const uint32_t DELIMITERS_LEN = 2;
+/* TODO: Default newline writing should be detected based upon the converter being used. */
+#else
+static const UChar DELIMITERS [] = { DELIM_LF, 0x0000 };
+static const uint32_t DELIMITERS_LEN = 1;
+#endif
+
+#define IS_FIRST_STRING_DELIMITER(c1) \
+ (UBool)((DELIM_LF <= (c1) && (c1) <= DELIM_CR) \
+        || (c1) == DELIM_NEL \
+        || (c1) == DELIM_LS \
+        || (c1) == DELIM_PS)
+#define CAN_HAVE_COMBINED_STRING_DELIMITER(c1) (UBool)((c1) == DELIM_CR)
+#define IS_COMBINED_STRING_DELIMITER(c1, c2) \
+ (UBool)((c1) == DELIM_CR && (c2) == DELIM_LF)
+
+
+#if !UCONFIG_NO_TRANSLITERATION
+
+U_CAPI UTransliterator* U_EXPORT2
+u_fsettransliterator(UFILE *file, UFileDirection direction,
+                     UTransliterator *adopt, UErrorCode *status)
+{
+    UTransliterator *old = NULL;
+
+    if(U_FAILURE(*status))
+    {
+        return adopt;
+    }
+
+    if(!file)
+    {
+        *status = U_ILLEGAL_ARGUMENT_ERROR;
+        return adopt;
+    }
+
+    if(direction & U_READ)
+    {
+        /** TODO: implement */
+        *status = U_UNSUPPORTED_ERROR;
+        return adopt;
+    }
+
+    if(adopt == NULL) /* they are clearing it */
+    {
+        if(file->fTranslit != NULL)
+        {
+            /* TODO: Check side */
+            old = file->fTranslit->translit;
+            uprv_free(file->fTranslit->buffer);
+            file->fTranslit->buffer=NULL;
+            uprv_free(file->fTranslit);
+            file->fTranslit=NULL;
+        }
+    }
+    else
+    {
+        if(file->fTranslit == NULL)
+        {
+            file->fTranslit = (UFILETranslitBuffer*) uprv_malloc(sizeof(UFILETranslitBuffer));
+            if(!file->fTranslit)
+            {
+                *status = U_MEMORY_ALLOCATION_ERROR;
+                return adopt;
+            }
+            file->fTranslit->capacity = 0;
+            file->fTranslit->length = 0;
+            file->fTranslit->pos = 0;
+            file->fTranslit->buffer = NULL;
+        }
+        else
+        {
+            old = file->fTranslit->translit;
+            ufile_flush_translit(file);
+        }
+
+        file->fTranslit->translit = adopt;
+    }
+
+    return old;
+}
+
+static const UChar * u_file_translit(UFILE *f, const UChar *src, int32_t *count, UBool flush)
+{
+    int32_t newlen;
+    int32_t junkCount = 0;
+    int32_t textLength;
+    int32_t textLimit;
+    UTransPosition pos;
+    UErrorCode status = U_ZERO_ERROR;
+
+    if(count == NULL)
+    {
+        count = &junkCount;
+    }
+
+    if ((!f)||(!f->fTranslit)||(!f->fTranslit->translit))
+    {
+        /* fast path */
+        return src;
+    }
+
+    /* First: slide over everything */
+    if(f->fTranslit->length > f->fTranslit->pos)
+    {
+        memmove(f->fTranslit->buffer, f->fTranslit->buffer + f->fTranslit->pos,
+            (f->fTranslit->length - f->fTranslit->pos)*sizeof(UChar));
+    }
+    f->fTranslit->length -= f->fTranslit->pos; /* always */
+    f->fTranslit->pos = 0;
+
+    /* Calculate new buffer size needed */
+    newlen = (*count + f->fTranslit->length) * 4;
+
+    if(newlen > f->fTranslit->capacity)
+    {
+        if(f->fTranslit->buffer == NULL)
+        {
+            f->fTranslit->buffer = (UChar*)uprv_malloc(newlen * sizeof(UChar));
+        }
+        else
+        {
+            f->fTranslit->buffer = (UChar*)uprv_realloc(f->fTranslit->buffer, newlen * sizeof(UChar));
+        }
+        f->fTranslit->capacity = newlen;
+    }
+
+    /* Now, copy any data over */
+    u_strncpy(f->fTranslit->buffer + f->fTranslit->length,
+        src,
+        *count);
+    f->fTranslit->length += *count;
+
+    /* Now, translit in place as much as we can  */
+    if(flush == FALSE)
+    {
+        textLength = f->fTranslit->length;
+        pos.contextStart = 0;
+        pos.contextLimit = textLength;
+        pos.start        = 0;
+        pos.limit        = textLength;
+
+        utrans_transIncrementalUChars(f->fTranslit->translit,
+            f->fTranslit->buffer, /* because we shifted */
+            &textLength,
+            f->fTranslit->capacity,
+            &pos,
+            &status);
+
+        /* now: start/limit point to the transliterated text */
+        /* Transliterated is [buffer..pos.start) */
+        *count            = pos.start;
+        f->fTranslit->pos = pos.start;
+        f->fTranslit->length = pos.limit;
+
+        return f->fTranslit->buffer;
+    }
+    else
+    {
+        textLength = f->fTranslit->length;
+        textLimit = f->fTranslit->length;
+
+        utrans_transUChars(f->fTranslit->translit,
+            f->fTranslit->buffer,
+            &textLength,
+            f->fTranslit->capacity,
+            0,
+            &textLimit,
+            &status);
+
+        /* out: converted len */
+        *count = textLimit;
+
+        /* Set pointers to 0 */
+        f->fTranslit->pos = 0;
+        f->fTranslit->length = 0;
+
+        return f->fTranslit->buffer;
+    }
+}
+
+#endif
+
+void
+ufile_flush_translit(UFILE *f)
+{
+#if !UCONFIG_NO_TRANSLITERATION
+    if((!f)||(!f->fTranslit))
+        return;
+#endif
+
+    u_file_write_flush(NULL, 0, f, FALSE, TRUE);
+}
+
+
+void
+ufile_close_translit(UFILE *f)
+{
+#if !UCONFIG_NO_TRANSLITERATION
+    if((!f)||(!f->fTranslit))
+        return;
+#endif
+
+    ufile_flush_translit(f);
+
+#if !UCONFIG_NO_TRANSLITERATION
+    if(f->fTranslit->translit)
+        utrans_close(f->fTranslit->translit);
+
+    if(f->fTranslit->buffer)
+    {
+        uprv_free(f->fTranslit->buffer);
+    }
+
+    uprv_free(f->fTranslit);
+    f->fTranslit = NULL;
+#endif
+}
+
+
+/* Input/output */
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fputs(const UChar    *s,
+        UFILE        *f)
+{
+    int32_t count = u_file_write(s, u_strlen(s), f);
+    count += u_file_write(DELIMITERS, DELIMITERS_LEN, f);
+    return count;
+}
+
+U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fputc(UChar32      uc,
+        UFILE        *f)
+{
+    UChar buf[2];
+    int32_t idx = 0;
+    UBool isError = FALSE;
+
+    U16_APPEND(buf, idx, sizeof(buf)/sizeof(*buf), uc, isError);
+    if (isError) {
+        return U_EOF;
+    }
+    return u_file_write(buf, idx, f) == idx ? uc : U_EOF;
+}
+
+
+U_CAPI int32_t U_EXPORT2
+u_file_write_flush(const UChar *chars,
+                   int32_t     count,
+                   UFILE       *f,
+                   UBool       flushIO,
+                   UBool       flushTranslit)
+{
+    /* Set up conversion parameters */
+    UErrorCode  status       = U_ZERO_ERROR;
+    const UChar *mySource    = chars;
+    const UChar *mySourceEnd;
+    char        charBuffer[UFILE_CHARBUFFER_SIZE];
+    char        *myTarget   = charBuffer;
+    int32_t     written      = 0;
+    int32_t     numConverted = 0;
+
+    if (count < 0) {
+        count = u_strlen(chars);
+    }
+
+#if !UCONFIG_NO_TRANSLITERATION
+    if((f->fTranslit) && (f->fTranslit->translit))
+    {
+        /* Do the transliteration */
+        mySource = u_file_translit(f, chars, &count, flushTranslit);
+    }
+#endif
+
+    /* Write to a string. */
+    if (!f->fFile) {
+        int32_t charsLeft = (int32_t)(f->str.fLimit - f->str.fPos);
+        if (flushIO && charsLeft > count) {
+            count++;
+        }
+        written = ufmt_min(count, charsLeft);
+        u_strncpy(f->str.fPos, mySource, written);
+        f->str.fPos += written;
+        return written;
+    }
+
+    mySourceEnd = mySource + count;
+
+    /* Perform the conversion in a loop */
+    do {
+        status     = U_ZERO_ERROR;
+        if(f->fConverter != NULL) { /* We have a valid converter */
+            ucnv_fromUnicode(f->fConverter,
+                &myTarget,
+                charBuffer + UFILE_CHARBUFFER_SIZE,
+                &mySource,
+                mySourceEnd,
+                NULL,
+                flushIO,
+                &status);
+        } else { /*weiv: do the invariant conversion */
+            u_UCharsToChars(mySource, myTarget, count);
+            myTarget += count;
+        }
+        numConverted = (int32_t)(myTarget - charBuffer);
+
+        if (numConverted > 0) {
+            /* write the converted bytes */
+            fwrite(charBuffer,
+                sizeof(char),
+                numConverted,
+                f->fFile);
+
+            written     += numConverted;
+        }
+        myTarget     = charBuffer;
+    }
+    while(status == U_BUFFER_OVERFLOW_ERROR);
+
+    /* return # of chars written */
+    return written;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_file_write(    const UChar     *chars,
+             int32_t        count,
+             UFILE         *f)
+{
+    return u_file_write_flush(chars,count,f,FALSE,FALSE);
+}
+
+
+/* private function used for buffering input */
+void
+ufile_fill_uchar_buffer(UFILE *f)
+{
+    UErrorCode  status;
+    const char  *mySource;
+    const char  *mySourceEnd;
+    UChar       *myTarget;
+    int32_t     bufferSize;
+    int32_t     maxCPBytes;
+    int32_t     bytesRead;
+    int32_t     availLength;
+    int32_t     dataSize;
+    char        charBuffer[UFILE_CHARBUFFER_SIZE];
+    u_localized_string *str;
+
+    if (f->fFile == NULL) {
+        /* There is nothing to do. It's a string. */
+        return;
+    }
+
+    str = &f->str;
+    dataSize = (int32_t)(str->fLimit - str->fPos);
+    if (f->fFileno == 0 && dataSize > 0) {
+        /* Don't read from stdin too many times. There is still some data. */
+        return;
+    }
+
+    /* shift the buffer if it isn't empty */
+    if(dataSize != 0) {
+        uprv_memmove(f->fUCBuffer, str->fPos, dataSize * sizeof(UChar));
+    }
+
+
+    /* record how much buffer space is available */
+    availLength = UFILE_UCHARBUFFER_SIZE - dataSize;
+
+    /* Determine the # of codepage bytes needed to fill our UChar buffer */
+    /* weiv: if converter is NULL, we use invariant converter with charwidth = 1)*/
+    maxCPBytes = availLength / (f->fConverter!=NULL?(2*ucnv_getMinCharSize(f->fConverter)):1);
+
+    /* Read in the data to convert */
+    if (f->fFileno == 0) {
+        /* Special case. Read from stdin one line at a time. */
+        char *retStr = fgets(charBuffer, ufmt_min(maxCPBytes, UFILE_CHARBUFFER_SIZE), f->fFile);
+        bytesRead = (int32_t)(retStr ? uprv_strlen(charBuffer) : 0);
+    }
+    else {
+        /* A normal file */
+        bytesRead = (int32_t)fread(charBuffer,
+            sizeof(char),
+            ufmt_min(maxCPBytes, UFILE_CHARBUFFER_SIZE),
+            f->fFile);
+    }
+
+    /* Set up conversion parameters */
+    status      = U_ZERO_ERROR;
+    mySource    = charBuffer;
+    mySourceEnd = charBuffer + bytesRead;
+    myTarget    = f->fUCBuffer + dataSize;
+    bufferSize  = UFILE_UCHARBUFFER_SIZE;
+
+    if(f->fConverter != NULL) { /* We have a valid converter */
+        /* Perform the conversion */
+        ucnv_toUnicode(f->fConverter,
+            &myTarget,
+            f->fUCBuffer + bufferSize,
+            &mySource,
+            mySourceEnd,
+            NULL,
+            (UBool)(feof(f->fFile) != 0),
+            &status);
+
+    } else { /*weiv: do the invariant conversion */
+        u_charsToUChars(mySource, myTarget, bytesRead);
+        myTarget += bytesRead;
+    }
+
+    /* update the pointers into our array */
+    str->fPos    = str->fBuffer;
+    str->fLimit  = myTarget;
+}
+
+U_CAPI UChar* U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgets(UChar        *s,
+        int32_t       n,
+        UFILE        *f)
+{
+    int32_t dataSize;
+    int32_t count;
+    UChar *alias;
+    const UChar *limit;
+    UChar *sItr;
+    UChar currDelim = 0;
+    u_localized_string *str;
+
+    if (n <= 0) {
+        /* Caller screwed up. We need to write the null terminatior. */
+        return NULL;
+    }
+
+    /* fill the buffer if needed */
+    str = &f->str;
+    if (str->fPos >= str->fLimit) {
+        ufile_fill_uchar_buffer(f);
+    }
+
+    /* subtract 1 from n to compensate for the terminator */
+    --n;
+
+    /* determine the amount of data in the buffer */
+    dataSize = (int32_t)(str->fLimit - str->fPos);
+
+    /* if 0 characters were left, return 0 */
+    if (dataSize == 0)
+        return NULL;
+
+    /* otherwise, iteratively fill the buffer and copy */
+    count = 0;
+    sItr = s;
+    currDelim = 0;
+    while (dataSize > 0 && count < n) {
+        alias = str->fPos;
+
+        /* Find how much to copy */
+        if (dataSize < (n - count)) {
+            limit = str->fLimit;
+        }
+        else {
+            limit = alias + (n - count);
+        }
+
+        if (!currDelim) {
+            /* Copy UChars until we find the first occurrence of a delimiter character */
+            while (alias < limit && !IS_FIRST_STRING_DELIMITER(*alias)) {
+                count++;
+                *(sItr++) = *(alias++);
+            }
+            /* Preserve the newline */
+            if (alias < limit && IS_FIRST_STRING_DELIMITER(*alias)) {
+                if (CAN_HAVE_COMBINED_STRING_DELIMITER(*alias)) {
+                    currDelim = *alias;
+                }
+                else {
+                    currDelim = 1;  /* This isn't a newline, but it's used to say
+                                    that we should break later. We've checked all
+                                    possible newline combinations even across buffer
+                                    boundaries. */
+                }
+                count++;
+                *(sItr++) = *(alias++);
+            }
+        }
+        /* If we have a CRLF combination, preserve that too. */
+        if (alias < limit) {
+            if (currDelim && IS_COMBINED_STRING_DELIMITER(currDelim, *alias)) {
+                count++;
+                *(sItr++) = *(alias++);
+            }
+            currDelim = 1;  /* This isn't a newline, but it's used to say
+                            that we should break later. We've checked all
+                            possible newline combinations even across buffer
+                            boundaries. */
+        }
+
+        /* update the current buffer position */
+        str->fPos = alias;
+
+        /* if we found a delimiter */
+        if (currDelim == 1) {
+            /* break out */
+            break;
+        }
+
+        /* refill the buffer */
+        ufile_fill_uchar_buffer(f);
+
+        /* determine the amount of data in the buffer */
+        dataSize = (int32_t)(str->fLimit - str->fPos);
+    }
+
+    /* add the terminator and return s */
+    *sItr = 0x0000;
+    return s;
+}
+
+U_CFUNC UBool U_EXPORT2
+ufile_getch(UFILE *f, UChar *ch)
+{
+    UBool isValidChar = FALSE;
+
+    *ch = U_EOF;
+    /* if we have an available character in the buffer, return it */
+    if(f->str.fPos < f->str.fLimit){
+        *ch = *(f->str.fPos)++;
+        isValidChar = TRUE;
+    }
+    else if (f) {
+        /* otherwise, fill the buffer and return the next character */
+        if(f->str.fPos >= f->str.fLimit) {
+            ufile_fill_uchar_buffer(f);
+        }
+        if(f->str.fPos < f->str.fLimit) {
+            *ch = *(f->str.fPos)++;
+            isValidChar = TRUE;
+        }
+    }
+    return isValidChar;
+}
+
+U_CAPI UChar U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetc(UFILE        *f)
+{
+    UChar ch;
+    ufile_getch(f, &ch);
+    return ch;
+}
+
+U_CFUNC UBool U_EXPORT2
+ufile_getch32(UFILE *f, UChar32 *c32)
+{
+    UBool isValidChar = FALSE;
+    u_localized_string *str;
+
+    *c32 = U_EOF;
+
+    /* Fill the buffer if it is empty */
+    str = &f->str;
+    if (f && str->fPos + 1 >= str->fLimit) {
+        ufile_fill_uchar_buffer(f);
+    }
+
+    /* Get the next character in the buffer */
+    if (str->fPos < str->fLimit) {
+        *c32 = *(str->fPos)++;
+        if (U_IS_LEAD(*c32)) {
+            if (str->fPos < str->fLimit) {
+                UChar c16 = *(str->fPos)++;
+                *c32 = U16_GET_SUPPLEMENTARY(*c32, c16);
+                isValidChar = TRUE;
+            }
+            else {
+                *c32 = U_EOF;
+            }
+        }
+        else {
+            isValidChar = TRUE;
+        }
+    }
+
+    return isValidChar;
+}
+
+U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fgetcx(UFILE        *f)
+{
+    UChar32 ch;
+    ufile_getch32(f, &ch);
+    return ch;
+}
+
+U_CAPI UChar32 U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_fungetc(UChar32        ch,
+    UFILE        *f)
+{
+    u_localized_string *str;
+
+    str = &f->str;
+
+    /* if we're at the beginning of the buffer, sorry! */
+    if (str->fPos == str->fBuffer
+        || (U_IS_LEAD(ch) && (str->fPos - 1) == str->fBuffer))
+    {
+        ch = U_EOF;
+    }
+    else {
+        /* otherwise, put the character back */
+        /* Remember, read them back on in the reverse order. */
+        if (U_IS_LEAD(ch)) {
+            if (*--(str->fPos) != U16_TRAIL(ch)
+                || *--(str->fPos) != U16_LEAD(ch))
+            {
+                ch = U_EOF;
+            }
+        }
+        else if (*--(str->fPos) != ch) {
+            ch = U_EOF;
+        }
+    }
+    return ch;
+}
+
+U_CAPI int32_t U_EXPORT2 /* U_CAPI ... U_EXPORT2 added by Peter Kirk 17 Nov 2001 */
+u_file_read(    UChar        *chars,
+    int32_t        count,
+    UFILE         *f)
+{
+    int32_t dataSize;
+    int32_t read = 0;
+    u_localized_string *str = &f->str;
+
+    do {
+
+        /* determine the amount of data in the buffer */
+        dataSize = (int32_t)(str->fLimit - str->fPos);
+        if (dataSize <= 0) {
+            /* fill the buffer */
+            ufile_fill_uchar_buffer(f);
+            dataSize = (int32_t)(str->fLimit - str->fPos);
+        }
+
+        /* Make sure that we don't read too much */
+        if (dataSize > (count - read)) {
+            dataSize = count - read;
+        }
+
+        /* copy the current data in the buffer */
+        memcpy(chars + read, str->fPos, dataSize * sizeof(UChar));
+
+        /* update number of items read */
+        read += dataSize;
+
+        /* update the current buffer position */
+        str->fPos += dataSize;
+    }
+    while (dataSize != 0 && read < count);
+
+    return read;
+}


Property changes on: trunk/source/io/ustdio.c
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/source/io/ustream.cpp
===================================================================
--- trunk/source/io/ustream.cpp	2006-12-21 10:45:40 UTC (rev 121)
+++ trunk/source/io/ustream.cpp	2006-12-21 10:47:20 UTC (rev 122)
@@ -1,143 +1,143 @@
-/*
-**********************************************************************
-*   Copyright (C) 2001-2006, International Business Machines
-*   Corporation and others.  All Rights Reserved.
-**********************************************************************
-*  FILE NAME : ustream.cpp
-*
-*   Modification History:
-*
-*   Date        Name        Description
-*   06/25/2001  grhoten     Move iostream from unistr.h to here
-******************************************************************************
-*/
-
-
-#include "unicode/utypes.h"
-#include "unicode/uobject.h"
-#include "unicode/ustream.h"
-#include "unicode/ucnv.h"
-#include "unicode/uchar.h"
-#include "ustr_cnv.h"
-#include <string.h>
-
-// console IO
-
-#if U_IOSTREAM_SOURCE >= 198506
-
-#if U_IOSTREAM_SOURCE >= 199711
-#define STD_NAMESPACE std::
-#else
-#define STD_NAMESPACE
-#endif
-
-#define STD_OSTREAM STD_NAMESPACE ostream
-#define STD_ISTREAM STD_NAMESPACE istream
-
-U_NAMESPACE_BEGIN
-
-U_IO_API STD_OSTREAM & U_EXPORT2
-operator<<(STD_OSTREAM& stream, const UnicodeString& str)
-{
-    if(str.length() > 0) {
-        char buffer[200];
-        UConverter *converter;
-        UErrorCode errorCode = U_ZERO_ERROR;
-
-        // use the default converter to convert chunks of text
-        converter = u_getDefaultConverter(&errorCode);
-        if(U_SUCCESS(errorCode)) {
-            const UChar *us = str.getBuffer();
-            const UChar *uLimit = us + str.length();
-            char *s, *sLimit = buffer + sizeof(buffer);
-            do {
-                errorCode = U_ZERO_ERROR;
-                s = buffer;
-                ucnv_fromUnicode(converter, &s, sLimit, &us, uLimit, 0, FALSE, &errorCode);
-
-                // write this chunk
-                if(s > buffer) {
-                    stream.write(buffer, (int32_t)(s - buffer));
-                }
-            } while(errorCode == U_BUFFER_OVERFLOW_ERROR);
-            u_releaseDefaultConverter(converter);
-        }
-    }
-
-/*    stream.flush();*/
-    return stream;
-}
-
-U_IO_API STD_ISTREAM & U_EXPORT2
-operator>>(STD_ISTREAM& stream, UnicodeString& str)
-{
-    /* ipfx should eat whitespace when ios::skipws is set */
-    UChar uBuffer[16];
-    char buffer[16];
-    int32_t idx = 0;
-    UConverter *converter;
-    UErrorCode errorCode = U_ZERO_ERROR;
-
-    str.truncate(0);
-    // use the default converter to convert chunks of text
-    converter = u_getDefaultConverter(&errorCode);
-    if(U_SUCCESS(errorCode)) {
-        UChar *us = uBuffer;
-        const UChar *uLimit = uBuffer + sizeof(uBuffer)/sizeof(*uBuffer);
-        const char *s, *sLimit;
-        char ch;
-        UChar ch32;
-        UBool intialWhitespace = TRUE;
-
-        /* We need to consume one byte at a time to see what is considered whitespace. */
-        while (!stream.eof()) {
-            ch = stream.get();
-            sLimit = &ch + 1;
-            errorCode = U_ZERO_ERROR;
-            us = uBuffer;
-            s = &ch;
-            ucnv_toUnicode(converter, &us, uLimit, &s, sLimit, 0, FALSE, &errorCode);
-            if(U_FAILURE(errorCode)) {
-                /* Something really bad happened */
-                return stream;
-            }
-            /* Was the character consumed? */
-            if (us != uBuffer) {
-                /* Reminder: ibm-1390 & JISX0213 can output 2 Unicode code points */
-                int32_t uBuffSize = us-uBuffer;
-                int32_t uBuffIdx = 0;
-                while (uBuffIdx < uBuffSize) {
-                    U16_NEXT(uBuffer, uBuffIdx, uBuffSize, ch32);
-                    if (u_isWhitespace(ch32)) {
-                        if (!intialWhitespace) {
-                            buffer[idx++] = ch;
-                            while (idx > 0) {
-                                stream.putback(buffer[--idx]);
-                            }
-                            goto STOP_READING;
-                        }
-                        /* else skip intialWhitespace */
-                    }
-                    else {
-                        str.append(ch32);
-                        intialWhitespace = FALSE;
-                    }
-                }
-                idx = 0;
-            }
-            else {
-                buffer[idx++] = ch;
-            }
-        }
-STOP_READING:
-        u_releaseDefaultConverter(converter);
-    }
-
-/*    stream.flush();*/
-    return stream;
-}
-
-U_NAMESPACE_END
-
-#endif
-
+/*
+**********************************************************************
+*   Copyright (C) 2001-2006, International Business Machines
+*   Corporation and others.  All Rights Reserved.
+**********************************************************************
+*  FILE NAME : ustream.cpp
+*
+*   Modification History:
+*
+*   Date        Name        Description
+*   06/25/2001  grhoten     Move iostream from unistr.h to here
+******************************************************************************
+*/
+
+
+#include "unicode/utypes.h"
+#include "unicode/uobject.h"
+#include "unicode/ustream.h"
+#include "unicode/ucnv.h"
+#include "unicode/uchar.h"
+#include "ustr_cnv.h"
+#include <string.h>
+
+// console IO
+
+#if U_IOSTREAM_SOURCE >= 198506
+
+#if U_IOSTREAM_SOURCE >= 199711
+#define STD_NAMESPACE std::
+#else
+#define STD_NAMESPACE
+#endif
+
+#define STD_OSTREAM STD_NAMESPACE ostream
+#define STD_ISTREAM STD_NAMESPACE istream
+
+U_NAMESPACE_BEGIN
+
+U_IO_API STD_OSTREAM & U_EXPORT2
+operator<<(STD_OSTREAM& stream, const UnicodeString& str)
+{
+    if(str.length() > 0) {
+        char buffer[200];
+        UConverter *converter;
+        UErrorCode errorCode = U_ZERO_ERROR;
+
+        // use the default converter to convert chunks of text
+        converter = u_getDefaultConverter(&errorCode);
+        if(U_SUCCESS(errorCode)) {
+            const UChar *us = str.getBuffer();
+            const UChar *uLimit = us + str.length();
+            char *s, *sLimit = buffer + sizeof(buffer);
+            do {
+                errorCode = U_ZERO_ERROR;
+                s = buffer;
+                ucnv_fromUnicode(converter, &s, sLimit, &us, uLimit, 0, FALSE, &errorCode);
+
+                // write this chunk
+                if(s > buffer) {
+                    stream.write(buffer, (int32_t)(s - buffer));
+                }
+            } while(errorCode == U_BUFFER_OVERFLOW_ERROR);
+            u_releaseDefaultConverter(converter);
+        }
+    }
+
+/*    stream.flush();*/
+    return stream;
+}
+
+U_IO_API STD_ISTREAM & U_EXPORT2
+operator>>(STD_ISTREAM& stream, UnicodeString& str)
+{
+    /* ipfx should eat whitespace when ios::skipws is set */
+    UChar uBuffer[16];
+    char buffer[16];
+    int32_t idx = 0;
+    UConverter *converter;
+    UErrorCode errorCode = U_ZERO_ERROR;
+
+    str.truncate(0);
+    // use the default converter to convert chunks of text
+    converter = u_getDefaultConverter(&errorCode);
+    if(U_SUCCESS(errorCode)) {
+        UChar *us = uBuffer;
+        const UChar *uLimit = uBuffer + sizeof(uBuffer)/sizeof(*uBuffer);
+        const char *s, *sLimit;
+        char ch;
+        UChar ch32;
+        UBool intialWhitespace = TRUE;
+
+        /* We need to consume one byte at a time to see what is considered whitespace. */
+        while (!stream.eof()) {
+            ch = stream.get();
+            sLimit = &ch + 1;
+            errorCode = U_ZERO_ERROR;
+            us = uBuffer;
+            s = &ch;
+            ucnv_toUnicode(converter, &us, uLimit, &s, sLimit, 0, FALSE, &errorCode);
+            if(U_FAILURE(errorCode)) {
+                /* Something really bad happened */
+                return stream;
+            }
+            /* Was the character consumed? */
+            if (us != uBuffer) {
+                /* Reminder: ibm-1390 & JISX0213 can output 2 Unicode code points */
+                int32_t uBuffSize = us-uBuffer;
+                int32_t uBuffIdx = 0;
+                while (uBuffIdx < uBuffSize) {
+                    U16_NEXT(uBuffer, uBuffIdx, uBuffSize, ch32);
+                    if (u_isWhitespace(ch32)) {
+                        if (!intialWhitespace) {
+                            buffer[idx++] = ch;
+                            while (idx > 0) {
+                                stream.putback(buffer[--idx]);
+                            }
+                            goto STOP_READING;
+                        }
+                        /* else skip intialWhitespace */
+                    }
+                    else {
+                        str.append(ch32);
+                        intialWhitespace = FALSE;
+                    }
+                }
+                idx = 0;
+            }
+            else {
+                buffer[idx++] = ch;
+            }
+        }
+STOP_READING:
+        u_releaseDefaultConverter(converter);
+    }
+
+/*    stream.flush();*/
+    return stream;
+}
+
+U_NAMESPACE_END
+
+#endif
+


Property changes on: trunk/source/io/ustream.cpp
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the sword-cvs mailing list