Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ustdio.h

Go to the documentation of this file.
00001 /*
00002 ******************************************************************************
00003 *
00004 *   Copyright (C) 1998-2001, International Business Machines
00005 *   Corporation and others.  All Rights Reserved.
00006 *
00007 ******************************************************************************
00008 *
00009 * File ustdio.h
00010 *
00011 * Modification History:
00012 *
00013 *   Date        Name        Description
00014 *   10/16/98    stephen     Creation.
00015 *   11/06/98    stephen     Modified per code review.
00016 *   03/12/99    stephen     Modified for new C API.
00017 *   07/19/99    stephen     Minor doc update.
00018 *   02/01/01    george      Added sprintf & sscanf with all of its variants
00019 ******************************************************************************
00020 */
00021 
00022 #ifndef USTDIO_H
00023 #define USTDIO_H
00024 
00025 #include <stdio.h>
00026 #include <stdarg.h>
00027 
00028 #include "unicode/utypes.h"
00029 #include "unicode/ucnv.h"
00030 
00031 /*
00032  The following is a small list as to what is currently wrong/suggestions for
00033  ustdio.
00034 
00035  * The const char* format specification should use unescape
00036  * ufile_locale2codepage should not be used.  Using one of putil.c's functions
00037     would be better or some new API would be better.
00038  * %D and %T printf uses the current timezone, but the scanf version uses GMT.
00039  * %p should be deprecated. Pointers are 2-16 bytes big and scanf should
00040     really read them.
00041  * The format specification should use int32_t and ICU type variants instead of
00042     the compiler dependent int.
00043  * We should consider using Microsoft's wprintf and wscanf format
00044     specification.
00045  * + in printf format specification is incomplete.
00046  * Make sure that #, blank and precision in the printf format specification
00047     works.
00048  * Make sure that * in the scanf format specification works.
00049  * e and g should lowercase the scientific notation.
00050  * E and F should uppercase the scientific notation.
00051  * Each UFILE takes up at least 2KB. This should be really reduced.
00052  * This library does buffering. The OS should do this for us already. Check on
00053     this, and remove it from this library, if this is the case. Double buffering
00054     wastes a lot of time and space.
00055  * There is a locale cache.  It needs to be cleaned up when the library unloads.
00056  * Make sure that surrogates are supported.
00057  * More testing is needed.
00058  * #include <iostream> from common/unicode/unistr.h should go into a new
00059     separate header (uios.h or ustream.h?) in the ustdio library.  Plenty of
00060     people do not use the iostream functionality for Unicode strings, and it
00061     will vastly speed up compilation time of .cpp files for those people that
00062     don't use it. In some cases, libraries that use ICU should not include
00063     iostream.  This new header file should also include operator<< and
00064     operator>> for UDate (not double) and UChar *.
00065  * fprintf/fscanf should use sprintf/sscanf in order to make testing easier.
00066  * Testing should be done for reading and writing multi-byte encodings,
00067     and make sure that a character that is contained across buffer boundries
00068     works even for incomplete characters.
00069  * Make sure that the last character is flushed when the file/string is closed.
00070 */
00071 
00072 
00073 #define U_EOF 0xFFFF
00074 
00076 typedef struct UFILE UFILE;
00077 
00078 
00079 
00098 U_CAPI UFILE* U_EXPORT2
00099 u_fopen(const char    *filename,
00100     const char    *perm,
00101     const char    *locale,
00102     const char    *codepage);
00103 
00117 U_CAPI UFILE* U_EXPORT2
00118 u_finit(FILE        *f,
00119     const char    *locale,
00120     const char    *codepage);
00121 
00127 U_CAPI void U_EXPORT2
00128 u_fclose(UFILE *file);
00129 
00136 U_CAPI FILE* U_EXPORT2
00137 u_fgetfile(UFILE *f);
00138 
00147 U_CAPI const char* U_EXPORT2
00148 u_fgetlocale(UFILE *file);
00149 
00158 U_CAPI int32_t U_EXPORT2
00159 u_fsetlocale(const char        *locale,
00160          UFILE        *file);
00161 
00171 U_CAPI const char* U_EXPORT2
00172 u_fgetcodepage(UFILE *file);
00173 
00186 U_CAPI int32_t U_EXPORT2
00187 u_fsetcodepage(const char    *codepage,
00188            UFILE        *file);
00189 
00190 
00197 U_CAPI UConverter* U_EXPORT2 u_fgetConverter(UFILE *f);
00198 
00199 /* Output functions */
00200 
00209 U_CAPI int32_t U_EXPORT2
00210 u_fprintf(    UFILE        *f,
00211         const char    *patternSpecification,
00212         ... );
00213 
00226 U_CAPI int32_t U_EXPORT2
00227 u_vfprintf(    UFILE        *f,
00228         const char    *patternSpecification,
00229         va_list        ap);
00230 
00239 U_CAPI int32_t U_EXPORT2
00240 u_fprintf_u(    UFILE        *f,
00241         const UChar    *patternSpecification,
00242         ... );
00243 
00256 U_CAPI int32_t U_EXPORT2
00257 u_vfprintf_u(    UFILE        *f,
00258         const UChar    *patternSpecification,
00259         va_list        ap);
00260 
00270 U_CAPI int32_t U_EXPORT2
00271 u_fputs(const UChar    *s,
00272     UFILE        *f);
00273 
00281 U_CAPI int32_t U_EXPORT2
00282 u_fputc(UChar        uc,
00283     UFILE        *f);
00284 
00295 U_CAPI int32_t U_EXPORT2
00296 u_file_write(const UChar     *chars, 
00297          int32_t        count, 
00298          UFILE         *f);
00299 
00300 
00301 /* Input functions */
00302 
00312 U_CAPI int32_t U_EXPORT2
00313 u_fscanf(    UFILE        *f,
00314         const char     *patternSpecification,
00315         ... );
00316 
00330 U_CAPI int32_t U_EXPORT2
00331 u_vfscanf(    UFILE        *f,
00332         const char     *patternSpecification,
00333         va_list        ap);
00334 
00344 U_CAPI int32_t U_EXPORT2
00345 u_fscanf_u(    UFILE        *f,
00346         const UChar     *patternSpecification,
00347         ... );
00348 
00362 U_CAPI int32_t U_EXPORT2
00363 u_vfscanf_u(    UFILE        *f,
00364         const UChar     *patternSpecification,
00365         va_list        ap);
00366 
00377 U_CAPI UChar* U_EXPORT2
00378 u_fgets(UFILE        *f,
00379     int32_t        n,
00380     UChar        *s);
00381 
00388 U_CAPI UChar U_EXPORT2
00389 u_fgetc(UFILE        *f);
00390 
00405 U_CAPI UChar32 U_EXPORT2
00406 u_fgetcx(UFILE        *f);
00407 
00417 U_CAPI UChar U_EXPORT2
00418 u_fungetc(UChar        c,
00419       UFILE        *f);
00420 
00431 U_CAPI int32_t U_EXPORT2
00432 u_file_read(UChar        *chars, 
00433         int32_t        count, 
00434         UFILE         *f);
00435 
00436 
00437 
00438 
00439 
00440 
00441 
00442 
00443 
00444 
00445 
00446 
00447 
00448 
00449 /* Output string functions */
00450 
00451 
00464 U_CAPI int32_t U_EXPORT2
00465 u_sprintf(UChar       *buffer,
00466         const char    *locale,
00467         const char    *patternSpecification,
00468         ... );
00469 
00488 U_CAPI int32_t U_EXPORT2
00489 u_snprintf(UChar      *buffer,
00490         int32_t       count,
00491         const char    *locale,
00492         const char    *patternSpecification,
00493         ... );
00494 
00510 U_CAPI int32_t U_EXPORT2
00511 u_vsprintf(UChar      *buffer,
00512         const char    *locale,
00513         const char    *patternSpecification,
00514         va_list        ap);
00515 
00537 U_CAPI int32_t U_EXPORT2
00538 u_vsnprintf(UChar     *buffer,
00539         int32_t       count,
00540         const char    *locale,
00541         const char    *patternSpecification,
00542         va_list        ap);
00543 
00555 U_CAPI int32_t U_EXPORT2
00556 u_sprintf_u(UChar      *buffer,
00557         const char     *locale,
00558         const UChar    *patternSpecification,
00559         ... );
00560 
00578 U_CAPI int32_t U_EXPORT2
00579 u_snprintf_u(UChar     *buffer,
00580         int32_t        count,
00581         const char     *locale,
00582         const UChar    *patternSpecification,
00583         ... );
00584 
00601 U_CAPI int32_t U_EXPORT2
00602 u_vsprintf_u(UChar     *buffer,
00603         const char    *locale,
00604         const UChar    *patternSpecification,
00605         va_list        ap);
00606 
00627 U_CAPI int32_t U_EXPORT2
00628 u_vsnprintf_u(UChar     *buffer,
00629         int32_t         count,
00630         const char     *locale,
00631         const UChar     *patternSpecification,
00632         va_list         ap);
00633 
00634 /* Input string functions */
00635 
00648 U_CAPI int32_t U_EXPORT2
00649 u_sscanf(UChar         *buffer,
00650         const char     *locale,
00651         const char     *patternSpecification,
00652         ... );
00653 
00670 U_CAPI int32_t U_EXPORT2
00671 u_vsscanf(UChar        *buffer,
00672         const char     *locale,
00673         const char     *patternSpecification,
00674         va_list        ap);
00675 
00688 U_CAPI int32_t U_EXPORT2
00689 u_sscanf_u(UChar        *buffer,
00690         const char      *locale,
00691         const UChar     *patternSpecification,
00692         ... );
00693 
00710 U_CAPI int32_t U_EXPORT2
00711 u_vsscanf_u(UChar       *buffer,
00712         const char      *locale,
00713         const UChar     *patternSpecification,
00714         va_list         ap);
00715 
00716 
00717 #endif
00718 
00719 

Generated on Mon Dec 3 19:00:28 2001 for ICU 2.0 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001