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; }
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 */ int32_t result = 0; /* test the return value of u_printf_parse */ 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 */ result = 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); /* parsing error */ if (result < 0) { return result; } /* return # of UChars written */ return written; }