Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE UFILE* U_EXPORT2 u_fstropen ( UChar *  stringBuf,
int32_t  capacity,
const char *  locale 

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.

stringBuf The string used for reading or writing.
capacity The number of code units available for use in stringBuf
locale The locale whose conventions will be used to format and parse output. If this parameter is NULL, the default locale will be used.
A new UFILE, or NULL if an error occurred. ICU 3.0

Definition at line 154 of file ufile.c.

References NULL.

    UFILE *result;

    if (capacity < 0) {
        return NULL;

    result = (UFILE*) uprv_malloc(sizeof(UFILE));
    /* Null pointer test */
    if (result == NULL) {
      return NULL; /* Just get out. */
    uprv_memset(result, 0, sizeof(UFILE));
    result->str.fBuffer = stringBuf;
    result->str.fPos    = stringBuf;
    result->str.fLimit  = stringBuf+capacity;

    /* if locale is 0, use the default */
    if(u_locbund_init(&result->str.fBundle, locale) == 0) {
        /* DO NOT FCLOSE HERE! */
        return 0;

    return result;

Generated by  Doxygen 1.6.0   Back to index