1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/i18n/unicode/umsg.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,623 @@ 1.4 +/******************************************************************** 1.5 + * COPYRIGHT: 1.6 + * Copyright (c) 1997-2011, International Business Machines Corporation and 1.7 + * others. All Rights Reserved. 1.8 + * Copyright (C) 2010 , Yahoo! Inc. 1.9 + ******************************************************************** 1.10 + * 1.11 + * file name: umsg.h 1.12 + * encoding: US-ASCII 1.13 + * tab size: 8 (not used) 1.14 + * indentation:4 1.15 + * 1.16 + * Change history: 1.17 + * 1.18 + * 08/5/2001 Ram Added C wrappers for C++ API. 1.19 + ********************************************************************/ 1.20 + 1.21 +#ifndef UMSG_H 1.22 +#define UMSG_H 1.23 + 1.24 +#include "unicode/utypes.h" 1.25 + 1.26 +#if !UCONFIG_NO_FORMATTING 1.27 + 1.28 +#include "unicode/localpointer.h" 1.29 +#include "unicode/uloc.h" 1.30 +#include "unicode/parseerr.h" 1.31 +#include <stdarg.h> 1.32 + 1.33 +/** 1.34 + * \file 1.35 + * \brief C API: MessageFormat 1.36 + * 1.37 + * <h2>MessageFormat C API </h2> 1.38 + * 1.39 + * <p>MessageFormat prepares strings for display to users, 1.40 + * with optional arguments (variables/placeholders). 1.41 + * The arguments can occur in any order, which is necessary for translation 1.42 + * into languages with different grammars. 1.43 + * 1.44 + * <p>The opaque UMessageFormat type is a thin C wrapper around 1.45 + * a C++ MessageFormat. It is constructed from a <em>pattern</em> string 1.46 + * with arguments in {curly braces} which will be replaced by formatted values. 1.47 + * 1.48 + * <p>Currently, the C API supports only numbered arguments. 1.49 + * 1.50 + * <p>For details about the pattern syntax and behavior, 1.51 + * especially about the ASCII apostrophe vs. the 1.52 + * real apostrophe (single quote) character \htmlonly’\endhtmlonly (U+2019), 1.53 + * see the C++ MessageFormat class documentation. 1.54 + * 1.55 + * <p>Here are some examples of C API usage: 1.56 + * Example 1: 1.57 + * <pre> 1.58 + * \code 1.59 + * UChar *result, *tzID, *str; 1.60 + * UChar pattern[100]; 1.61 + * int32_t resultLengthOut, resultlength; 1.62 + * UCalendar *cal; 1.63 + * UDate d1; 1.64 + * UDateFormat *def1; 1.65 + * UErrorCode status = U_ZERO_ERROR; 1.66 + * 1.67 + * str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1)); 1.68 + * u_uastrcpy(str, "disturbance in force"); 1.69 + * tzID=(UChar*)malloc(sizeof(UChar) * 4); 1.70 + * u_uastrcpy(tzID, "PST"); 1.71 + * cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status); 1.72 + * ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status); 1.73 + * d1=ucal_getMillis(cal, &status); 1.74 + * u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}"); 1.75 + * resultlength=0; 1.76 + * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7); 1.77 + * if(status==U_BUFFER_OVERFLOW_ERROR){ 1.78 + * status=U_ZERO_ERROR; 1.79 + * resultlength=resultLengthOut+1; 1.80 + * result=(UChar*)realloc(result, sizeof(UChar) * resultlength); 1.81 + * u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7); 1.82 + * } 1.83 + * printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*) 1.84 + * //output>: "On March 18, 1999, there was a disturbance in force on planet 7 1.85 + * \endcode 1.86 + * </pre> 1.87 + * Typically, the message format will come from resources, and the 1.88 + * arguments will be dynamically set at runtime. 1.89 + * <P> 1.90 + * Example 2: 1.91 + * <pre> 1.92 + * \code 1.93 + * UChar* str; 1.94 + * UErrorCode status = U_ZERO_ERROR; 1.95 + * UChar *result; 1.96 + * UChar pattern[100]; 1.97 + * int32_t resultlength, resultLengthOut, i; 1.98 + * double testArgs= { 100.0, 1.0, 0.0}; 1.99 + * 1.100 + * str=(UChar*)malloc(sizeof(UChar) * 10); 1.101 + * u_uastrcpy(str, "MyDisk"); 1.102 + * u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}"); 1.103 + * for(i=0; i<3; i++){ 1.104 + * resultlength=0; 1.105 + * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); 1.106 + * if(status==U_BUFFER_OVERFLOW_ERROR){ 1.107 + * status=U_ZERO_ERROR; 1.108 + * resultlength=resultLengthOut+1; 1.109 + * result=(UChar*)malloc(sizeof(UChar) * resultlength); 1.110 + * u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str); 1.111 + * } 1.112 + * printf("%s\n", austrdup(result) ); //austrdup( a function used to convert UChar* to char*) 1.113 + * free(result); 1.114 + * } 1.115 + * // output, with different testArgs: 1.116 + * // output: The disk "MyDisk" contains 100 files. 1.117 + * // output: The disk "MyDisk" contains one file. 1.118 + * // output: The disk "MyDisk" contains no files. 1.119 + * \endcode 1.120 + * </pre> 1.121 + * 1.122 + * 1.123 + * Example 3: 1.124 + * <pre> 1.125 + * \code 1.126 + * UChar* str; 1.127 + * UChar* str1; 1.128 + * UErrorCode status = U_ZERO_ERROR; 1.129 + * UChar *result; 1.130 + * UChar pattern[100]; 1.131 + * UChar expected[100]; 1.132 + * int32_t resultlength,resultLengthOut; 1.133 + 1.134 + * str=(UChar*)malloc(sizeof(UChar) * 25); 1.135 + * u_uastrcpy(str, "Kirti"); 1.136 + * str1=(UChar*)malloc(sizeof(UChar) * 25); 1.137 + * u_uastrcpy(str1, "female"); 1.138 + * log_verbose("Testing message format with Select test #1\n:"); 1.139 + * u_uastrcpy(pattern, "{0} est {1, select, female {all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris."); 1.140 + * u_uastrcpy(expected, "Kirti est all\\u00E9e \\u00E0 Paris."); 1.141 + * resultlength=0; 1.142 + * resultLengthOut=u_formatMessage( "fr", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1); 1.143 + * if(status==U_BUFFER_OVERFLOW_ERROR) 1.144 + * { 1.145 + * status=U_ZERO_ERROR; 1.146 + * resultlength=resultLengthOut+1; 1.147 + * result=(UChar*)malloc(sizeof(UChar) * resultlength); 1.148 + * u_formatMessage( "fr", pattern, u_strlen(pattern), result, resultlength, &status, str , str1); 1.149 + * if(u_strcmp(result, expected)==0) 1.150 + * log_verbose("PASS: MessagFormat successful on Select test#1\n"); 1.151 + * else{ 1.152 + * log_err("FAIL: Error in MessageFormat on Select test#1\n GOT %s EXPECTED %s\n", austrdup(result), 1.153 + * austrdup(expected) ); 1.154 + * } 1.155 + * free(result); 1.156 + * } 1.157 + * \endcode 1.158 + * </pre> 1.159 + */ 1.160 + 1.161 +/** 1.162 + * Format a message for a locale. 1.163 + * This function may perform re-ordering of the arguments depending on the 1.164 + * locale. For all numeric arguments, double is assumed unless the type is 1.165 + * explicitly integer. All choice format arguments must be of type double. 1.166 + * @param locale The locale for which the message will be formatted 1.167 + * @param pattern The pattern specifying the message's format 1.168 + * @param patternLength The length of pattern 1.169 + * @param result A pointer to a buffer to receive the formatted message. 1.170 + * @param resultLength The maximum size of result. 1.171 + * @param status A pointer to an UErrorCode to receive any errors 1.172 + * @param ... A variable-length argument list containing the arguments specified 1.173 + * in pattern. 1.174 + * @return The total buffer size needed; if greater than resultLength, the 1.175 + * output was truncated. 1.176 + * @see u_parseMessage 1.177 + * @stable ICU 2.0 1.178 + */ 1.179 +U_STABLE int32_t U_EXPORT2 1.180 +u_formatMessage(const char *locale, 1.181 + const UChar *pattern, 1.182 + int32_t patternLength, 1.183 + UChar *result, 1.184 + int32_t resultLength, 1.185 + UErrorCode *status, 1.186 + ...); 1.187 + 1.188 +/** 1.189 + * Format a message for a locale. 1.190 + * This function may perform re-ordering of the arguments depending on the 1.191 + * locale. For all numeric arguments, double is assumed unless the type is 1.192 + * explicitly integer. All choice format arguments must be of type double. 1.193 + * @param locale The locale for which the message will be formatted 1.194 + * @param pattern The pattern specifying the message's format 1.195 + * @param patternLength The length of pattern 1.196 + * @param result A pointer to a buffer to receive the formatted message. 1.197 + * @param resultLength The maximum size of result. 1.198 + * @param ap A variable-length argument list containing the arguments specified 1.199 + * @param status A pointer to an UErrorCode to receive any errors 1.200 + * in pattern. 1.201 + * @return The total buffer size needed; if greater than resultLength, the 1.202 + * output was truncated. 1.203 + * @see u_parseMessage 1.204 + * @stable ICU 2.0 1.205 + */ 1.206 +U_STABLE int32_t U_EXPORT2 1.207 +u_vformatMessage( const char *locale, 1.208 + const UChar *pattern, 1.209 + int32_t patternLength, 1.210 + UChar *result, 1.211 + int32_t resultLength, 1.212 + va_list ap, 1.213 + UErrorCode *status); 1.214 + 1.215 +/** 1.216 + * Parse a message. 1.217 + * For numeric arguments, this function will always use doubles. Integer types 1.218 + * should not be passed. 1.219 + * This function is not able to parse all output from {@link #u_formatMessage }. 1.220 + * @param locale The locale for which the message is formatted 1.221 + * @param pattern The pattern specifying the message's format 1.222 + * @param patternLength The length of pattern 1.223 + * @param source The text to parse. 1.224 + * @param sourceLength The length of source, or -1 if null-terminated. 1.225 + * @param status A pointer to an UErrorCode to receive any errors 1.226 + * @param ... A variable-length argument list containing the arguments 1.227 + * specified in pattern. 1.228 + * @see u_formatMessage 1.229 + * @stable ICU 2.0 1.230 + */ 1.231 +U_STABLE void U_EXPORT2 1.232 +u_parseMessage( const char *locale, 1.233 + const UChar *pattern, 1.234 + int32_t patternLength, 1.235 + const UChar *source, 1.236 + int32_t sourceLength, 1.237 + UErrorCode *status, 1.238 + ...); 1.239 + 1.240 +/** 1.241 + * Parse a message. 1.242 + * For numeric arguments, this function will always use doubles. Integer types 1.243 + * should not be passed. 1.244 + * This function is not able to parse all output from {@link #u_formatMessage }. 1.245 + * @param locale The locale for which the message is formatted 1.246 + * @param pattern The pattern specifying the message's format 1.247 + * @param patternLength The length of pattern 1.248 + * @param source The text to parse. 1.249 + * @param sourceLength The length of source, or -1 if null-terminated. 1.250 + * @param ap A variable-length argument list containing the arguments 1.251 + * @param status A pointer to an UErrorCode to receive any errors 1.252 + * specified in pattern. 1.253 + * @see u_formatMessage 1.254 + * @stable ICU 2.0 1.255 + */ 1.256 +U_STABLE void U_EXPORT2 1.257 +u_vparseMessage(const char *locale, 1.258 + const UChar *pattern, 1.259 + int32_t patternLength, 1.260 + const UChar *source, 1.261 + int32_t sourceLength, 1.262 + va_list ap, 1.263 + UErrorCode *status); 1.264 + 1.265 +/** 1.266 + * Format a message for a locale. 1.267 + * This function may perform re-ordering of the arguments depending on the 1.268 + * locale. For all numeric arguments, double is assumed unless the type is 1.269 + * explicitly integer. All choice format arguments must be of type double. 1.270 + * @param locale The locale for which the message will be formatted 1.271 + * @param pattern The pattern specifying the message's format 1.272 + * @param patternLength The length of pattern 1.273 + * @param result A pointer to a buffer to receive the formatted message. 1.274 + * @param resultLength The maximum size of result. 1.275 + * @param status A pointer to an UErrorCode to receive any errors 1.276 + * @param ... A variable-length argument list containing the arguments specified 1.277 + * in pattern. 1.278 + * @param parseError A pointer to UParseError to receive information about errors 1.279 + * occurred during parsing. 1.280 + * @return The total buffer size needed; if greater than resultLength, the 1.281 + * output was truncated. 1.282 + * @see u_parseMessage 1.283 + * @stable ICU 2.0 1.284 + */ 1.285 +U_STABLE int32_t U_EXPORT2 1.286 +u_formatMessageWithError( const char *locale, 1.287 + const UChar *pattern, 1.288 + int32_t patternLength, 1.289 + UChar *result, 1.290 + int32_t resultLength, 1.291 + UParseError *parseError, 1.292 + UErrorCode *status, 1.293 + ...); 1.294 + 1.295 +/** 1.296 + * Format a message for a locale. 1.297 + * This function may perform re-ordering of the arguments depending on the 1.298 + * locale. For all numeric arguments, double is assumed unless the type is 1.299 + * explicitly integer. All choice format arguments must be of type double. 1.300 + * @param locale The locale for which the message will be formatted 1.301 + * @param pattern The pattern specifying the message's format 1.302 + * @param patternLength The length of pattern 1.303 + * @param result A pointer to a buffer to receive the formatted message. 1.304 + * @param resultLength The maximum size of result. 1.305 + * @param parseError A pointer to UParseError to receive information about errors 1.306 + * occurred during parsing. 1.307 + * @param ap A variable-length argument list containing the arguments specified 1.308 + * @param status A pointer to an UErrorCode to receive any errors 1.309 + * in pattern. 1.310 + * @return The total buffer size needed; if greater than resultLength, the 1.311 + * output was truncated. 1.312 + * @stable ICU 2.0 1.313 + */ 1.314 +U_STABLE int32_t U_EXPORT2 1.315 +u_vformatMessageWithError( const char *locale, 1.316 + const UChar *pattern, 1.317 + int32_t patternLength, 1.318 + UChar *result, 1.319 + int32_t resultLength, 1.320 + UParseError* parseError, 1.321 + va_list ap, 1.322 + UErrorCode *status); 1.323 + 1.324 +/** 1.325 + * Parse a message. 1.326 + * For numeric arguments, this function will always use doubles. Integer types 1.327 + * should not be passed. 1.328 + * This function is not able to parse all output from {@link #u_formatMessage }. 1.329 + * @param locale The locale for which the message is formatted 1.330 + * @param pattern The pattern specifying the message's format 1.331 + * @param patternLength The length of pattern 1.332 + * @param source The text to parse. 1.333 + * @param sourceLength The length of source, or -1 if null-terminated. 1.334 + * @param parseError A pointer to UParseError to receive information about errors 1.335 + * occurred during parsing. 1.336 + * @param status A pointer to an UErrorCode to receive any errors 1.337 + * @param ... A variable-length argument list containing the arguments 1.338 + * specified in pattern. 1.339 + * @see u_formatMessage 1.340 + * @stable ICU 2.0 1.341 + */ 1.342 +U_STABLE void U_EXPORT2 1.343 +u_parseMessageWithError(const char *locale, 1.344 + const UChar *pattern, 1.345 + int32_t patternLength, 1.346 + const UChar *source, 1.347 + int32_t sourceLength, 1.348 + UParseError *parseError, 1.349 + UErrorCode *status, 1.350 + ...); 1.351 + 1.352 +/** 1.353 + * Parse a message. 1.354 + * For numeric arguments, this function will always use doubles. Integer types 1.355 + * should not be passed. 1.356 + * This function is not able to parse all output from {@link #u_formatMessage }. 1.357 + * @param locale The locale for which the message is formatted 1.358 + * @param pattern The pattern specifying the message's format 1.359 + * @param patternLength The length of pattern 1.360 + * @param source The text to parse. 1.361 + * @param sourceLength The length of source, or -1 if null-terminated. 1.362 + * @param ap A variable-length argument list containing the arguments 1.363 + * @param parseError A pointer to UParseError to receive information about errors 1.364 + * occurred during parsing. 1.365 + * @param status A pointer to an UErrorCode to receive any errors 1.366 + * specified in pattern. 1.367 + * @see u_formatMessage 1.368 + * @stable ICU 2.0 1.369 + */ 1.370 +U_STABLE void U_EXPORT2 1.371 +u_vparseMessageWithError(const char *locale, 1.372 + const UChar *pattern, 1.373 + int32_t patternLength, 1.374 + const UChar *source, 1.375 + int32_t sourceLength, 1.376 + va_list ap, 1.377 + UParseError *parseError, 1.378 + UErrorCode* status); 1.379 + 1.380 +/*----------------------- New experimental API --------------------------- */ 1.381 +/** 1.382 + * The message format object 1.383 + * @stable ICU 2.0 1.384 + */ 1.385 +typedef void* UMessageFormat; 1.386 + 1.387 + 1.388 +/** 1.389 + * Open a message formatter with given pattern and for the given locale. 1.390 + * @param pattern A pattern specifying the format to use. 1.391 + * @param patternLength Length of the pattern to use 1.392 + * @param locale The locale for which the messages are formatted. 1.393 + * @param parseError A pointer to UParseError struct to receive any errors 1.394 + * occured during parsing. Can be NULL. 1.395 + * @param status A pointer to an UErrorCode to receive any errors. 1.396 + * @return A pointer to a UMessageFormat to use for formatting 1.397 + * messages, or 0 if an error occurred. 1.398 + * @stable ICU 2.0 1.399 + */ 1.400 +U_STABLE UMessageFormat* U_EXPORT2 1.401 +umsg_open( const UChar *pattern, 1.402 + int32_t patternLength, 1.403 + const char *locale, 1.404 + UParseError *parseError, 1.405 + UErrorCode *status); 1.406 + 1.407 +/** 1.408 + * Close a UMessageFormat. 1.409 + * Once closed, a UMessageFormat may no longer be used. 1.410 + * @param format The formatter to close. 1.411 + * @stable ICU 2.0 1.412 + */ 1.413 +U_STABLE void U_EXPORT2 1.414 +umsg_close(UMessageFormat* format); 1.415 + 1.416 +#if U_SHOW_CPLUSPLUS_API 1.417 + 1.418 +U_NAMESPACE_BEGIN 1.419 + 1.420 +/** 1.421 + * \class LocalUMessageFormatPointer 1.422 + * "Smart pointer" class, closes a UMessageFormat via umsg_close(). 1.423 + * For most methods see the LocalPointerBase base class. 1.424 + * 1.425 + * @see LocalPointerBase 1.426 + * @see LocalPointer 1.427 + * @stable ICU 4.4 1.428 + */ 1.429 +U_DEFINE_LOCAL_OPEN_POINTER(LocalUMessageFormatPointer, UMessageFormat, umsg_close); 1.430 + 1.431 +U_NAMESPACE_END 1.432 + 1.433 +#endif 1.434 + 1.435 +/** 1.436 + * Open a copy of a UMessageFormat. 1.437 + * This function performs a deep copy. 1.438 + * @param fmt The formatter to copy 1.439 + * @param status A pointer to an UErrorCode to receive any errors. 1.440 + * @return A pointer to a UDateFormat identical to fmt. 1.441 + * @stable ICU 2.0 1.442 + */ 1.443 +U_STABLE UMessageFormat U_EXPORT2 1.444 +umsg_clone(const UMessageFormat *fmt, 1.445 + UErrorCode *status); 1.446 + 1.447 +/** 1.448 + * Sets the locale. This locale is used for fetching default number or date 1.449 + * format information. 1.450 + * @param fmt The formatter to set 1.451 + * @param locale The locale the formatter should use. 1.452 + * @stable ICU 2.0 1.453 + */ 1.454 +U_STABLE void U_EXPORT2 1.455 +umsg_setLocale(UMessageFormat *fmt, 1.456 + const char* locale); 1.457 + 1.458 +/** 1.459 + * Gets the locale. This locale is used for fetching default number or date 1.460 + * format information. 1.461 + * @param fmt The formatter to querry 1.462 + * @return the locale. 1.463 + * @stable ICU 2.0 1.464 + */ 1.465 +U_STABLE const char* U_EXPORT2 1.466 +umsg_getLocale(const UMessageFormat *fmt); 1.467 + 1.468 +/** 1.469 + * Sets the pattern. 1.470 + * @param fmt The formatter to use 1.471 + * @param pattern The pattern to be applied. 1.472 + * @param patternLength Length of the pattern to use 1.473 + * @param parseError Struct to receive information on position 1.474 + * of error if an error is encountered.Can be NULL. 1.475 + * @param status Output param set to success/failure code on 1.476 + * exit. If the pattern is invalid, this will be 1.477 + * set to a failure result. 1.478 + * @stable ICU 2.0 1.479 + */ 1.480 +U_STABLE void U_EXPORT2 1.481 +umsg_applyPattern( UMessageFormat *fmt, 1.482 + const UChar* pattern, 1.483 + int32_t patternLength, 1.484 + UParseError* parseError, 1.485 + UErrorCode* status); 1.486 + 1.487 +/** 1.488 + * Gets the pattern. 1.489 + * @param fmt The formatter to use 1.490 + * @param result A pointer to a buffer to receive the pattern. 1.491 + * @param resultLength The maximum size of result. 1.492 + * @param status Output param set to success/failure code on 1.493 + * exit. If the pattern is invalid, this will be 1.494 + * set to a failure result. 1.495 + * @return the pattern of the format 1.496 + * @stable ICU 2.0 1.497 + */ 1.498 +U_STABLE int32_t U_EXPORT2 1.499 +umsg_toPattern(const UMessageFormat *fmt, 1.500 + UChar* result, 1.501 + int32_t resultLength, 1.502 + UErrorCode* status); 1.503 + 1.504 +/** 1.505 + * Format a message for a locale. 1.506 + * This function may perform re-ordering of the arguments depending on the 1.507 + * locale. For all numeric arguments, double is assumed unless the type is 1.508 + * explicitly integer. All choice format arguments must be of type double. 1.509 + * @param fmt The formatter to use 1.510 + * @param result A pointer to a buffer to receive the formatted message. 1.511 + * @param resultLength The maximum size of result. 1.512 + * @param status A pointer to an UErrorCode to receive any errors 1.513 + * @param ... A variable-length argument list containing the arguments 1.514 + * specified in pattern. 1.515 + * @return The total buffer size needed; if greater than resultLength, 1.516 + * the output was truncated. 1.517 + * @stable ICU 2.0 1.518 + */ 1.519 +U_STABLE int32_t U_EXPORT2 1.520 +umsg_format( const UMessageFormat *fmt, 1.521 + UChar *result, 1.522 + int32_t resultLength, 1.523 + UErrorCode *status, 1.524 + ...); 1.525 + 1.526 +/** 1.527 + * Format a message for a locale. 1.528 + * This function may perform re-ordering of the arguments depending on the 1.529 + * locale. For all numeric arguments, double is assumed unless the type is 1.530 + * explicitly integer. All choice format arguments must be of type double. 1.531 + * @param fmt The formatter to use 1.532 + * @param result A pointer to a buffer to receive the formatted message. 1.533 + * @param resultLength The maximum size of result. 1.534 + * @param ap A variable-length argument list containing the arguments 1.535 + * @param status A pointer to an UErrorCode to receive any errors 1.536 + * specified in pattern. 1.537 + * @return The total buffer size needed; if greater than resultLength, 1.538 + * the output was truncated. 1.539 + * @stable ICU 2.0 1.540 + */ 1.541 +U_STABLE int32_t U_EXPORT2 1.542 +umsg_vformat( const UMessageFormat *fmt, 1.543 + UChar *result, 1.544 + int32_t resultLength, 1.545 + va_list ap, 1.546 + UErrorCode *status); 1.547 + 1.548 +/** 1.549 + * Parse a message. 1.550 + * For numeric arguments, this function will always use doubles. Integer types 1.551 + * should not be passed. 1.552 + * This function is not able to parse all output from {@link #umsg_format }. 1.553 + * @param fmt The formatter to use 1.554 + * @param source The text to parse. 1.555 + * @param sourceLength The length of source, or -1 if null-terminated. 1.556 + * @param count Output param to receive number of elements returned. 1.557 + * @param status A pointer to an UErrorCode to receive any errors 1.558 + * @param ... A variable-length argument list containing the arguments 1.559 + * specified in pattern. 1.560 + * @stable ICU 2.0 1.561 + */ 1.562 +U_STABLE void U_EXPORT2 1.563 +umsg_parse( const UMessageFormat *fmt, 1.564 + const UChar *source, 1.565 + int32_t sourceLength, 1.566 + int32_t *count, 1.567 + UErrorCode *status, 1.568 + ...); 1.569 + 1.570 +/** 1.571 + * Parse a message. 1.572 + * For numeric arguments, this function will always use doubles. Integer types 1.573 + * should not be passed. 1.574 + * This function is not able to parse all output from {@link #umsg_format }. 1.575 + * @param fmt The formatter to use 1.576 + * @param source The text to parse. 1.577 + * @param sourceLength The length of source, or -1 if null-terminated. 1.578 + * @param count Output param to receive number of elements returned. 1.579 + * @param ap A variable-length argument list containing the arguments 1.580 + * @param status A pointer to an UErrorCode to receive any errors 1.581 + * specified in pattern. 1.582 + * @see u_formatMessage 1.583 + * @stable ICU 2.0 1.584 + */ 1.585 +U_STABLE void U_EXPORT2 1.586 +umsg_vparse(const UMessageFormat *fmt, 1.587 + const UChar *source, 1.588 + int32_t sourceLength, 1.589 + int32_t *count, 1.590 + va_list ap, 1.591 + UErrorCode *status); 1.592 + 1.593 + 1.594 +/** 1.595 + * Convert an 'apostrophe-friendly' pattern into a standard 1.596 + * pattern. Standard patterns treat all apostrophes as 1.597 + * quotes, which is problematic in some languages, e.g. 1.598 + * French, where apostrophe is commonly used. This utility 1.599 + * assumes that only an unpaired apostrophe immediately before 1.600 + * a brace is a true quote. Other unpaired apostrophes are paired, 1.601 + * and the resulting standard pattern string is returned. 1.602 + * 1.603 + * <p><b>Note</b> it is not guaranteed that the returned pattern 1.604 + * is indeed a valid pattern. The only effect is to convert 1.605 + * between patterns having different quoting semantics. 1.606 + * 1.607 + * @param pattern the 'apostrophe-friendly' patttern to convert 1.608 + * @param patternLength the length of pattern, or -1 if unknown and pattern is null-terminated 1.609 + * @param dest the buffer for the result, or NULL if preflight only 1.610 + * @param destCapacity the length of the buffer, or 0 if preflighting 1.611 + * @param ec the error code 1.612 + * @return the length of the resulting text, not including trailing null 1.613 + * if buffer has room for the trailing null, it is provided, otherwise 1.614 + * not 1.615 + * @stable ICU 3.4 1.616 + */ 1.617 +U_STABLE int32_t U_EXPORT2 1.618 +umsg_autoQuoteApostrophe(const UChar* pattern, 1.619 + int32_t patternLength, 1.620 + UChar* dest, 1.621 + int32_t destCapacity, 1.622 + UErrorCode* ec); 1.623 + 1.624 +#endif /* #if !UCONFIG_NO_FORMATTING */ 1.625 + 1.626 +#endif