From df03c9748cebd9bfe7b1f40b54be371a4aced843 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 19 Sep 2011 17:58:14 +0000 Subject: [PATCH] ICU-8579 added u_printf_u and u_get_stdout X-SVN-Rev: 30685 --- icu4c/source/io/unicode/ustdio.h | 19 +++++++++++++++++++ icu4c/source/io/uprintf.c | 14 +++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/icu4c/source/io/unicode/ustdio.h b/icu4c/source/io/unicode/ustdio.h index cae7d9baf8a..145b1f44b0a 100644 --- a/icu4c/source/io/unicode/ustdio.h +++ b/icu4c/source/io/unicode/ustdio.h @@ -482,6 +482,25 @@ u_vfprintf(UFILE *f, const char *patternSpecification, va_list ap); +/** + * Write formatted data to stdout. + * @param patternSpecification A pattern specifying how u_printf_u will + * interpret the variable arguments received and format the data. + * @return The number of Unicode characters written to stdout + * @draft ICU 49 + */ +U_DRAFT int32_t U_EXPORT2 +u_printf_u(const UChar *patternSpecification, + ... ); + +/** + * Get a UFILE for stdout. + * @return UFILE that writes to stdout + * @draft ICU 49 + */ +U_DRAFT UFILE * U_EXPORT2 +u_get_stdout(); + /** * Write formatted data to a UFILE. * @param f The UFILE to which to write. diff --git a/icu4c/source/io/uprintf.c b/icu4c/source/io/uprintf.c index deea3e09430..01e9c6ba1d9 100644 --- a/icu4c/source/io/uprintf.c +++ b/icu4c/source/io/uprintf.c @@ -46,7 +46,7 @@ static UBool U_CALLCONV uprintf_cleanup() return TRUE; } -static UFILE * U_EXPORT2 +U_CAPI UFILE * U_EXPORT2 u_get_stdout() { if (gStdOut == NULL) { @@ -141,6 +141,18 @@ u_fprintf_u( UFILE *f, return count; } +U_CAPI int32_t U_EXPORT2 +u_printf_u(const UChar *patternSpecification, + ...) +{ + va_list ap; + int32_t count; + va_start(ap, patternSpecification); + count = u_vfprintf_u(u_get_stdout(), 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,