]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/io/unicode/ustdio.h
ICU-511.25.tar.gz
[apple/icu.git] / icuSources / io / unicode / ustdio.h
index cc0b6d7ae47a5b5408a859113ab34836160ffec2..e29ad22b49654ebf7dfb47686c2a8cdbaa1afa51 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1998-2004, International Business Machines
+*   Copyright (C) 1998-2013, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -28,6 +28,8 @@
 #include "unicode/utypes.h"
 #include "unicode/ucnv.h"
 #include "unicode/utrans.h"
+#include "unicode/localpointer.h"
+#include "unicode/unum.h"
 
 /*
     TODO
  * \brief C API: Unicode stdio-like API
  *
  * <h2>Unicode stdio-like C API</h2>
-General printf format:<br>
-%[format modifier][width][.precision][type modifier][format]
-
-General scanf format:<br>
-%[*][format modifier][width][type modifier][format]
-
+ *
+ * <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>type</td><td>description</td></tr>
-<tr><td>%E</td><td>double</td><td>Scientific with an uppercase exponent</td></tr>
-<tr><td>%e</td><td>double</td><td>Scientific with a lowercase exponent</td></tr>
-<tr><td>%G</td><td>double</td><td>Use %E or %f for best format</td></tr>
-<tr><td>%g</td><td>double</td><td>Use %e or %f for best format</td></tr>
-<tr><td>%f</td><td>double</td><td>Simple floating point without the exponent</td></tr>
-<tr><td>%X</td><td>int32_t</td><td>ustdio special uppercase hex radix formatting</td></tr>
-<tr><td>%x</td><td>int32_t</td><td>ustdio special lowercase hex radix formatting</td></tr>
-<tr><td>%d</td><td>int32_t</td><td>Decimal format</td></tr>
-<tr><td>%i</td><td>int32_t</td><td>Same as %d</td></tr>
-<tr><td>%n</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>ustdio special octal radix formatting</td></tr>
-<tr><td>%u</td><td>uint32_t</td><td>Decimal format</td></tr>
-<tr><td>%p</td><td>void *</td><td>Prints the pointer value</td></tr>
-<tr><td>%s</td><td>char *</td><td>Use default converter or specified converter from fopen</td></tr>
-<tr><td>%c</td><td>char</td><td>Use default converter or specified converter from fopen<br>
-When width is specified, this acts like a non-NULL-terminated char * string.<br>
+<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>Null terminated UTF-16 string</td></tr>
-<tr><td>%C</td><td>UChar</td><td>16-bit Unicode code unit<br>
-When width is specified, this acts like a non-NULL-terminated UChar * string<br>
+<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>UChar *</td><td>(scanf only) Null terminated UTF-16 string which contains the filtered set of characters specified by the UnicodeSet</td></tr>
-<tr><td>%%</td><td>N/A</td><td>Show a percent sign</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
@@ -156,23 +182,35 @@ printf modifier
 scanf modifier
 %*  N/A         This field is scanned, but not stored
 
+<p>If you are using this C API instead of the ustream.h API for C++,
+you can use one of the following u_fprintf examples to display a UnicodeString.</p>
+
+<pre><code>
+    UFILE *out = u_finit(stdout, NULL, NULL);
+    UnicodeString string1("string 1");
+    UnicodeString string2("string 2");
+    u_fprintf(out, "%S\n", string1.getTerminatedBuffer());
+    u_fprintf(out, "%.*S\n", string2.length(), string2.getBuffer());
+    u_fclose(out);
+</code></pre>
+
  */
 
 
 /**
  * When an end of file is encountered, this value can be returned.
  * @see u_fgetc
- * @draft 3.0
+ * @stable 3.0
  */
 #define U_EOF 0xFFFF
 
-/** Forward declaration of a Unicode-aware file @draft 3.0 */
+/** Forward declaration of a Unicode-aware file @stable 3.0 */
 typedef struct UFILE UFILE;
 
 /**
  * Enum for which direction of stream a transliterator applies to.
  * @see u_fsettransliterator
- * @draft 3.0
+ * @stable ICU 3.0
  */
 typedef enum { 
    U_READ = 1,
@@ -195,17 +233,20 @@ typedef enum {
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI UFILE* U_EXPORT2
+U_STABLE 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.
+ * Open a UFILE on top of an existing FILE* stream. The FILE* stream
+ * ownership remains with the caller. To have the UFILE take over
+ * ownership and responsibility for the FILE* stream, use the
+ * function u_fadopt.
+ * @param f The FILE* to which this UFILE will attach and use.
  * @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.
@@ -214,13 +255,34 @@ u_fopen(const char    *filename,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI UFILE* U_EXPORT2
+U_STABLE UFILE* U_EXPORT2
 u_finit(FILE        *f,
     const char    *locale,
     const char    *codepage);
 
+/**
+ * Open a UFILE on top of an existing FILE* stream. The FILE* stream
+ * ownership is transferred to the new UFILE. It will be closed when the
+ * UFILE is closed.
+ * @param f The FILE* which this UFILE will take ownership of.
+ * @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. If an error occurs
+ * the ownership of the FILE* stream remains with the caller.
+ * @stable ICU 4.4
+ */
+U_STABLE UFILE* U_EXPORT2
+u_fadopt(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
@@ -233,30 +295,50 @@ u_finit(FILE        *f,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI UFILE* U_EXPORT2
+U_STABLE UFILE* U_EXPORT2
 u_fstropen(UChar      *stringBuf,
            int32_t     capacity,
            const char *locale);
 
 /**
- * Close a UFILE.
+ * Close a UFILE. Implies u_fflush first.
  * @param file The UFILE to close.
- * @draft 3.0
+ * @stable ICU 3.0
+ * @see u_fflush
  */
-U_CAPI void U_EXPORT2
+U_STABLE void U_EXPORT2
 u_fclose(UFILE *file);
 
+#if U_SHOW_CPLUSPLUS_API
+
+U_NAMESPACE_BEGIN
+
+/**
+ * \class LocalUFILEPointer
+ * "Smart pointer" class, closes a UFILE via u_fclose().
+ * For most methods see the LocalPointerBase base class.
+ *
+ * @see LocalPointerBase
+ * @see LocalPointer
+ * @stable ICU 4.4
+ */
+U_DEFINE_LOCAL_OPEN_POINTER(LocalUFILEPointer, UFILE, u_fclose);
+
+U_NAMESPACE_END
+
+#endif
+
 /**
  * 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
+ * @stable ICU 3.0
 */
-U_CAPI UBool U_EXPORT2
+U_STABLE UBool U_EXPORT2
 u_feof(UFILE  *f);
 
 /**
@@ -264,27 +346,29 @@ u_feof(UFILE  *f);
  * 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.
+ * Note that for a stateful encoding, the converter may write additional
+ * bytes to return the stream to default state.
  * @param file The UFILE to flush.
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI void U_EXPORT2
+U_STABLE 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
+ * @stable ICU 3.0
  */
-U_CAPI void
+U_STABLE 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
+ * @return A FILE*, owned by the UFILE. (The FILE <EM>must not</EM> be modified or closed)
+ * @stable ICU 3.0
  */
-U_CAPI FILE* U_EXPORT2
+U_STABLE FILE* U_EXPORT2
 u_fgetfile(UFILE *f);
 
 #if !UCONFIG_NO_FORMATTING
@@ -295,9 +379,9 @@ u_fgetfile(UFILE *f);
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI const char* U_EXPORT2
+U_STABLE const char* U_EXPORT2
 u_fgetlocale(UFILE *file);
 
 /**
@@ -306,9 +390,9 @@ u_fgetlocale(UFILE *file);
  * and parse output.
  * @param file The UFILE to query.
  * @return NULL if successful, otherwise a negative number.
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fsetlocale(UFILE      *file,
              const char *locale);
 
@@ -321,9 +405,9 @@ u_fsetlocale(UFILE      *file,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI const char* U_EXPORT2
+U_STABLE const char* U_EXPORT2
 u_fgetcodepage(UFILE *file);
 
 /**
@@ -333,15 +417,15 @@ u_fgetcodepage(UFILE *file);
  * 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>.
+ * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fsetcodepage(const char   *codepage,
                UFILE        *file);
 
@@ -349,24 +433,44 @@ u_fsetcodepage(const char   *codepage,
 /**
  * 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
+ * @return alias to the converter (The converter <EM>must not</EM> be modified or closed)
+ * @stable ICU 3.0
  */
-U_CAPI UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
+U_STABLE UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
 
 #if !UCONFIG_NO_FORMATTING
+#ifndef U_HIDE_DRAFT_API
+/**
+ * Returns an alias to the number formatter being used for this file.
+ * @param f The UFILE to get the value from
+ * @return alias to the number formatter (The formatter <EM>must not</EM> be modified or closed)
+ * @draft ICU 51
+*/
+ U_DRAFT const UNumberFormat* U_EXPORT2 u_fgetNumberFormat(UFILE *f);
+#endif /* U_HIDE_DRAFT_API */
 
 /* Output functions */
 
+/**
+ * Write formatted data to <TT>stdout</TT>.
+ * @param patternSpecification A pattern specifying how <TT>u_printf</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>stdout</TT>
+ * @stable ICU 49
+ */
+U_STABLE int32_t U_EXPORT2
+u_printf(const char *patternSpecification,
+         ... );
+
 /**
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fprintf(UFILE         *f,
           const char    *patternSpecification,
           ... );
@@ -381,22 +485,41 @@ u_fprintf(UFILE         *f,
  * @param ap The argument list to use.
  * @return The number of Unicode characters written to <TT>f</TT>.
  * @see u_fprintf
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vfprintf(UFILE        *f,
            const char   *patternSpecification,
            va_list      ap);
 
+/**
+ * Write formatted data to <TT>stdout</TT>.
+ * @param patternSpecification A pattern specifying how <TT>u_printf_u</TT> will
+ * interpret the variable arguments received and format the data.
+ * @return The number of Unicode characters written to <TT>stdout</TT>
+ * @stable ICU 49
+ */
+U_STABLE int32_t U_EXPORT2
+u_printf_u(const UChar *patternSpecification,
+           ... );
+
+/**
+ * Get a UFILE for <TT>stdout</TT>.
+ * @return UFILE that writes to <TT>stdout</TT>
+ * @stable ICU 49
+ */
+U_STABLE UFILE * U_EXPORT2
+u_get_stdout(void);
+
 /**
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fprintf_u(UFILE       *f,
             const UChar *patternSpecification,
             ... );
@@ -411,9 +534,9 @@ u_fprintf_u(UFILE       *f,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vfprintf_u(UFILE      *f,
             const UChar *patternSpecification,
             va_list     ap);
@@ -426,9 +549,9 @@ u_vfprintf_u(UFILE      *f,
  * @param f The UFILE to which to write.
  * @return A non-negative number if successful, EOF otherwise.
  * @see u_file_write
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fputs(const UChar *s,
         UFILE       *f);
 
@@ -437,9 +560,9 @@ u_fputs(const UChar *s,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 u_fputc(UChar32  uc,
         UFILE  *f);
 
@@ -452,9 +575,9 @@ u_fputc(UChar32  uc,
  * @param f The UFILE to which to write.
  * @return The number of Unicode characters written.
  * @see u_fputs
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_file_write(const UChar    *ustring, 
              int32_t        count, 
              UFILE          *f);
@@ -470,9 +593,9 @@ u_file_write(const UChar    *ustring,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fscanf(UFILE      *f,
          const char *patternSpecification,
          ... );
@@ -488,9 +611,9 @@ u_fscanf(UFILE      *f,
  * @return The number of items successfully converted and assigned, or EOF
  * if an error occurred.
  * @see u_fscanf
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vfscanf(UFILE         *f,
           const char    *patternSpecification,
           va_list        ap);
@@ -502,9 +625,9 @@ u_vfscanf(UFILE         *f,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_fscanf_u(UFILE        *f,
            const UChar  *patternSpecification,
            ... );
@@ -520,9 +643,9 @@ u_fscanf_u(UFILE        *f,
  * @return The number of items successfully converted and assigned, or EOF
  * if an error occurred.
  * @see u_fscanf_u
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vfscanf_u(UFILE       *f,
             const UChar *patternSpecification,
             va_list      ap);
@@ -538,9 +661,9 @@ u_vfscanf_u(UFILE       *f,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI UChar* U_EXPORT2
+U_STABLE UChar* U_EXPORT2
 u_fgets(UChar  *s,
         int32_t n,
         UFILE  *f);
@@ -552,9 +675,9 @@ u_fgets(UChar  *s,
  *
  * @param f The UFILE from which to read.
  * @return The UChar value read, or U+FFFF if no character was available.
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI UChar U_EXPORT2
+U_STABLE UChar U_EXPORT2
 u_fgetc(UFILE   *f);
 
 /**
@@ -565,9 +688,9 @@ u_fgetc(UFILE   *f);
  * available, or U+FFFFFFFF if an ill-formed character was
  * encountered.
  * @see u_unescape()
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 u_fgetcx(UFILE  *f);
 
 /**
@@ -579,9 +702,9 @@ u_fgetcx(UFILE  *f);
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI UChar32 U_EXPORT2
+U_STABLE UChar32 U_EXPORT2
 u_fungetc(UChar32   c,
       UFILE        *f);
 
@@ -593,9 +716,9 @@ u_fungetc(UChar32   c,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_file_read(UChar        *chars, 
         int32_t        count, 
         UFILE         *f);
@@ -617,9 +740,9 @@ u_file_read(UChar        *chars,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI UTransliterator* U_EXPORT2
+U_STABLE UTransliterator* U_EXPORT2
 u_fsettransliterator(UFILE *file, UFileDirection direction,
                      UTransliterator *adopt, UErrorCode *status);
 
@@ -638,9 +761,9 @@ u_fsettransliterator(UFILE *file, UFileDirection direction,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_sprintf(UChar       *buffer,
         const char    *patternSpecification,
         ... );
@@ -657,11 +780,12 @@ u_sprintf(UChar       *buffer,
  * @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
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large. This does not include
+ * the terminating null character.
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_snprintf(UChar      *buffer,
         int32_t       count,
         const char    *patternSpecification,
@@ -678,9 +802,9 @@ u_snprintf(UChar      *buffer,
  * @param ap The argument list to use.
  * @return The number of Unicode characters written to <TT>buffer</TT>.
  * @see u_sprintf
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsprintf(UChar      *buffer,
         const char    *patternSpecification,
         va_list        ap);
@@ -700,11 +824,12 @@ u_vsprintf(UChar      *buffer,
  * @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>.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large.
  * @see u_sprintf
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsnprintf(UChar     *buffer,
         int32_t       count,
         const char    *patternSpecification,
@@ -717,9 +842,9 @@ u_vsnprintf(UChar     *buffer,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_sprintf_u(UChar      *buffer,
         const UChar    *patternSpecification,
         ... );
@@ -736,10 +861,11 @@ u_sprintf_u(UChar      *buffer,
  * @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
+ * @return The number of Unicode characters that would have been written to
+ * <TT>buffer</TT> had count been sufficiently large.
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_snprintf_u(UChar     *buffer,
         int32_t        count,
         const UChar    *patternSpecification,
@@ -756,9 +882,9 @@ u_snprintf_u(UChar     *buffer,
  * @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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsprintf_u(UChar     *buffer,
         const UChar    *patternSpecification,
         va_list        ap);
@@ -778,11 +904,12 @@ u_vsprintf_u(UChar     *buffer,
  * @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>.
+ * @return The number of Unicode characters that would have been written to
+ * <TT>f</TT> had count been sufficiently large.
  * @see u_sprintf_u
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsnprintf_u(UChar *buffer,
         int32_t         count,
         const UChar     *patternSpecification,
@@ -798,9 +925,9 @@ u_vsnprintf_u(UChar *buffer,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_sscanf(const UChar   *buffer,
         const char     *patternSpecification,
         ... );
@@ -817,9 +944,9 @@ u_sscanf(const UChar   *buffer,
  * @return The number of items successfully converted and assigned, or EOF
  * if an error occurred.
  * @see u_sscanf
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsscanf(const UChar  *buffer,
         const char     *patternSpecification,
         va_list        ap);
@@ -832,9 +959,9 @@ u_vsscanf(const UChar  *buffer,
  * 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
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_sscanf_u(const UChar  *buffer,
         const UChar     *patternSpecification,
         ... );
@@ -851,9 +978,9 @@ u_sscanf_u(const UChar  *buffer,
  * @return The number of items successfully converted and assigned, or EOF
  * if an error occurred.
  * @see u_sscanf_u
- * @draft 3.0
+ * @stable ICU 3.0
  */
-U_CAPI int32_t U_EXPORT2
+U_STABLE int32_t U_EXPORT2
 u_vsscanf_u(const UChar *buffer,
         const UChar     *patternSpecification,
         va_list         ap);