michael@0: /******************************************************************** michael@0: * COPYRIGHT: michael@0: * Copyright (c) 1997-2011, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: * Copyright (C) 2010 , Yahoo! Inc. michael@0: ******************************************************************** michael@0: * michael@0: * file name: umsg.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * Change history: michael@0: * michael@0: * 08/5/2001 Ram Added C wrappers for C++ API. michael@0: ********************************************************************/ michael@0: michael@0: #ifndef UMSG_H michael@0: #define UMSG_H michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/localpointer.h" michael@0: #include "unicode/uloc.h" michael@0: #include "unicode/parseerr.h" michael@0: #include michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: MessageFormat michael@0: * michael@0: *

MessageFormat C API

michael@0: * michael@0: *

MessageFormat prepares strings for display to users, michael@0: * with optional arguments (variables/placeholders). michael@0: * The arguments can occur in any order, which is necessary for translation michael@0: * into languages with different grammars. michael@0: * michael@0: *

The opaque UMessageFormat type is a thin C wrapper around michael@0: * a C++ MessageFormat. It is constructed from a pattern string michael@0: * with arguments in {curly braces} which will be replaced by formatted values. michael@0: * michael@0: *

Currently, the C API supports only numbered arguments. michael@0: * michael@0: *

For details about the pattern syntax and behavior, michael@0: * especially about the ASCII apostrophe vs. the michael@0: * real apostrophe (single quote) character \htmlonly’\endhtmlonly (U+2019), michael@0: * see the C++ MessageFormat class documentation. michael@0: * michael@0: *

Here are some examples of C API usage: michael@0: * Example 1: michael@0: *

michael@0:  * \code
michael@0:  *     UChar *result, *tzID, *str;
michael@0:  *     UChar pattern[100];
michael@0:  *     int32_t resultLengthOut, resultlength;
michael@0:  *     UCalendar *cal;
michael@0:  *     UDate d1;
michael@0:  *     UDateFormat *def1;
michael@0:  *     UErrorCode status = U_ZERO_ERROR;
michael@0:  *
michael@0:  *     str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1));
michael@0:  *     u_uastrcpy(str, "disturbance in force");
michael@0:  *     tzID=(UChar*)malloc(sizeof(UChar) * 4);
michael@0:  *     u_uastrcpy(tzID, "PST");
michael@0:  *     cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
michael@0:  *     ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);
michael@0:  *     d1=ucal_getMillis(cal, &status);
michael@0:  *     u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}");
michael@0:  *     resultlength=0;
michael@0:  *     resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);
michael@0:  *     if(status==U_BUFFER_OVERFLOW_ERROR){
michael@0:  *         status=U_ZERO_ERROR;
michael@0:  *         resultlength=resultLengthOut+1;
michael@0:  *         result=(UChar*)realloc(result, sizeof(UChar) * resultlength);
michael@0:  *         u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);
michael@0:  *     }
michael@0:  *     printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*)
michael@0:  *     //output>: "On March 18, 1999, there was a disturbance in force on planet 7
michael@0:  * \endcode
michael@0:  * 
michael@0: * Typically, the message format will come from resources, and the michael@0: * arguments will be dynamically set at runtime. michael@0: *

michael@0: * Example 2: michael@0: *

michael@0:  * \code
michael@0:  *     UChar* str;
michael@0:  *     UErrorCode status = U_ZERO_ERROR;
michael@0:  *     UChar *result;
michael@0:  *     UChar pattern[100];
michael@0:  *     int32_t resultlength, resultLengthOut, i;
michael@0:  *     double testArgs= { 100.0, 1.0, 0.0};
michael@0:  *
michael@0:  *     str=(UChar*)malloc(sizeof(UChar) * 10);
michael@0:  *     u_uastrcpy(str, "MyDisk");
michael@0:  *     u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
michael@0:  *     for(i=0; i<3; i++){
michael@0:  *       resultlength=0; 
michael@0:  *       resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str); 
michael@0:  *       if(status==U_BUFFER_OVERFLOW_ERROR){
michael@0:  *         status=U_ZERO_ERROR;
michael@0:  *         resultlength=resultLengthOut+1;
michael@0:  *         result=(UChar*)malloc(sizeof(UChar) * resultlength);
michael@0:  *         u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
michael@0:  *       }
michael@0:  *       printf("%s\n", austrdup(result) );  //austrdup( a function used to convert UChar* to char*)
michael@0:  *       free(result);
michael@0:  *     }
michael@0:  *     // output, with different testArgs:
michael@0:  *     // output: The disk "MyDisk" contains 100 files.
michael@0:  *     // output: The disk "MyDisk" contains one file.
michael@0:  *     // output: The disk "MyDisk" contains no files.
michael@0:  * \endcode
michael@0:  *  
michael@0: * michael@0: * michael@0: * Example 3: michael@0: *
michael@0:  * \code
michael@0:  * UChar* str;
michael@0:  * UChar* str1;
michael@0:  * UErrorCode status = U_ZERO_ERROR;
michael@0:  * UChar *result;
michael@0:  * UChar pattern[100];
michael@0:  * UChar expected[100];
michael@0:  * int32_t resultlength,resultLengthOut;
michael@0: 
michael@0:  * str=(UChar*)malloc(sizeof(UChar) * 25);
michael@0:  * u_uastrcpy(str, "Kirti");
michael@0:  * str1=(UChar*)malloc(sizeof(UChar) * 25);
michael@0:  * u_uastrcpy(str1, "female");
michael@0:  * log_verbose("Testing message format with Select test #1\n:");
michael@0:  * u_uastrcpy(pattern, "{0} est {1, select, female {all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris.");
michael@0:  * u_uastrcpy(expected, "Kirti est all\\u00E9e \\u00E0 Paris.");
michael@0:  * resultlength=0;
michael@0:  * resultLengthOut=u_formatMessage( "fr", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1);
michael@0:  * if(status==U_BUFFER_OVERFLOW_ERROR)
michael@0:  *  {
michael@0:  *      status=U_ZERO_ERROR;
michael@0:  *      resultlength=resultLengthOut+1;
michael@0:  *      result=(UChar*)malloc(sizeof(UChar) * resultlength);
michael@0:  *      u_formatMessage( "fr", pattern, u_strlen(pattern), result, resultlength, &status, str , str1);
michael@0:  *      if(u_strcmp(result, expected)==0)
michael@0:  *          log_verbose("PASS: MessagFormat successful on Select test#1\n");
michael@0:  *      else{
michael@0:  *          log_err("FAIL: Error in MessageFormat on Select test#1\n GOT %s EXPECTED %s\n", austrdup(result),
michael@0:  *          austrdup(expected) );
michael@0:  *      }
michael@0:  *      free(result);
michael@0:  * }
michael@0:  * \endcode
michael@0:  *  
michael@0: */ michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param locale The locale for which the message will be formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments specified michael@0: * in pattern. michael@0: * @return The total buffer size needed; if greater than resultLength, the michael@0: * output was truncated. michael@0: * @see u_parseMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: u_formatMessage(const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param locale The locale for which the message will be formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param ap A variable-length argument list containing the arguments specified michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * in pattern. michael@0: * @return The total buffer size needed; if greater than resultLength, the michael@0: * output was truncated. michael@0: * @see u_parseMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: u_vformatMessage( const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: va_list ap, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #u_formatMessage }. michael@0: * @param locale The locale for which the message is formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments michael@0: * specified in pattern. michael@0: * @see u_formatMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: u_parseMessage( const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #u_formatMessage }. michael@0: * @param locale The locale for which the message is formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param ap A variable-length argument list containing the arguments michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * specified in pattern. michael@0: * @see u_formatMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: u_vparseMessage(const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: va_list ap, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param locale The locale for which the message will be formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments specified michael@0: * in pattern. michael@0: * @param parseError A pointer to UParseError to receive information about errors michael@0: * occurred during parsing. michael@0: * @return The total buffer size needed; if greater than resultLength, the michael@0: * output was truncated. michael@0: * @see u_parseMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: u_formatMessageWithError( const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: UParseError *parseError, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param locale The locale for which the message will be formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param parseError A pointer to UParseError to receive information about errors michael@0: * occurred during parsing. michael@0: * @param ap A variable-length argument list containing the arguments specified michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * in pattern. michael@0: * @return The total buffer size needed; if greater than resultLength, the michael@0: * output was truncated. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: u_vformatMessageWithError( const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: UParseError* parseError, michael@0: va_list ap, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #u_formatMessage }. michael@0: * @param locale The locale for which the message is formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param parseError A pointer to UParseError to receive information about errors michael@0: * occurred during parsing. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments michael@0: * specified in pattern. michael@0: * @see u_formatMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: u_parseMessageWithError(const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: UParseError *parseError, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #u_formatMessage }. michael@0: * @param locale The locale for which the message is formatted michael@0: * @param pattern The pattern specifying the message's format michael@0: * @param patternLength The length of pattern michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param ap A variable-length argument list containing the arguments michael@0: * @param parseError A pointer to UParseError to receive information about errors michael@0: * occurred during parsing. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * specified in pattern. michael@0: * @see u_formatMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: u_vparseMessageWithError(const char *locale, michael@0: const UChar *pattern, michael@0: int32_t patternLength, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: va_list ap, michael@0: UParseError *parseError, michael@0: UErrorCode* status); michael@0: michael@0: /*----------------------- New experimental API --------------------------- */ michael@0: /** michael@0: * The message format object michael@0: * @stable ICU 2.0 michael@0: */ michael@0: typedef void* UMessageFormat; michael@0: michael@0: michael@0: /** michael@0: * Open a message formatter with given pattern and for the given locale. michael@0: * @param pattern A pattern specifying the format to use. michael@0: * @param patternLength Length of the pattern to use michael@0: * @param locale The locale for which the messages are formatted. michael@0: * @param parseError A pointer to UParseError struct to receive any errors michael@0: * occured during parsing. Can be NULL. michael@0: * @param status A pointer to an UErrorCode to receive any errors. michael@0: * @return A pointer to a UMessageFormat to use for formatting michael@0: * messages, or 0 if an error occurred. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE UMessageFormat* U_EXPORT2 michael@0: umsg_open( const UChar *pattern, michael@0: int32_t patternLength, michael@0: const char *locale, michael@0: UParseError *parseError, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Close a UMessageFormat. michael@0: * Once closed, a UMessageFormat may no longer be used. michael@0: * @param format The formatter to close. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: umsg_close(UMessageFormat* format); michael@0: michael@0: #if U_SHOW_CPLUSPLUS_API michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: /** michael@0: * \class LocalUMessageFormatPointer michael@0: * "Smart pointer" class, closes a UMessageFormat via umsg_close(). michael@0: * For most methods see the LocalPointerBase base class. michael@0: * michael@0: * @see LocalPointerBase michael@0: * @see LocalPointer michael@0: * @stable ICU 4.4 michael@0: */ michael@0: U_DEFINE_LOCAL_OPEN_POINTER(LocalUMessageFormatPointer, UMessageFormat, umsg_close); michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif michael@0: michael@0: /** michael@0: * Open a copy of a UMessageFormat. michael@0: * This function performs a deep copy. michael@0: * @param fmt The formatter to copy michael@0: * @param status A pointer to an UErrorCode to receive any errors. michael@0: * @return A pointer to a UDateFormat identical to fmt. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE UMessageFormat U_EXPORT2 michael@0: umsg_clone(const UMessageFormat *fmt, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Sets the locale. This locale is used for fetching default number or date michael@0: * format information. michael@0: * @param fmt The formatter to set michael@0: * @param locale The locale the formatter should use. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: umsg_setLocale(UMessageFormat *fmt, michael@0: const char* locale); michael@0: michael@0: /** michael@0: * Gets the locale. This locale is used for fetching default number or date michael@0: * format information. michael@0: * @param fmt The formatter to querry michael@0: * @return the locale. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE const char* U_EXPORT2 michael@0: umsg_getLocale(const UMessageFormat *fmt); michael@0: michael@0: /** michael@0: * Sets the pattern. michael@0: * @param fmt The formatter to use michael@0: * @param pattern The pattern to be applied. michael@0: * @param patternLength Length of the pattern to use michael@0: * @param parseError Struct to receive information on position michael@0: * of error if an error is encountered.Can be NULL. michael@0: * @param status Output param set to success/failure code on michael@0: * exit. If the pattern is invalid, this will be michael@0: * set to a failure result. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: umsg_applyPattern( UMessageFormat *fmt, michael@0: const UChar* pattern, michael@0: int32_t patternLength, michael@0: UParseError* parseError, michael@0: UErrorCode* status); michael@0: michael@0: /** michael@0: * Gets the pattern. michael@0: * @param fmt The formatter to use michael@0: * @param result A pointer to a buffer to receive the pattern. michael@0: * @param resultLength The maximum size of result. michael@0: * @param status Output param set to success/failure code on michael@0: * exit. If the pattern is invalid, this will be michael@0: * set to a failure result. michael@0: * @return the pattern of the format michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: umsg_toPattern(const UMessageFormat *fmt, michael@0: UChar* result, michael@0: int32_t resultLength, michael@0: UErrorCode* status); michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param fmt The formatter to use michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments michael@0: * specified in pattern. michael@0: * @return The total buffer size needed; if greater than resultLength, michael@0: * the output was truncated. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: umsg_format( const UMessageFormat *fmt, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Format a message for a locale. michael@0: * This function may perform re-ordering of the arguments depending on the michael@0: * locale. For all numeric arguments, double is assumed unless the type is michael@0: * explicitly integer. All choice format arguments must be of type double. michael@0: * @param fmt The formatter to use michael@0: * @param result A pointer to a buffer to receive the formatted message. michael@0: * @param resultLength The maximum size of result. michael@0: * @param ap A variable-length argument list containing the arguments michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * specified in pattern. michael@0: * @return The total buffer size needed; if greater than resultLength, michael@0: * the output was truncated. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: umsg_vformat( const UMessageFormat *fmt, michael@0: UChar *result, michael@0: int32_t resultLength, michael@0: va_list ap, michael@0: UErrorCode *status); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #umsg_format }. michael@0: * @param fmt The formatter to use michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param count Output param to receive number of elements returned. michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * @param ... A variable-length argument list containing the arguments michael@0: * specified in pattern. michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: umsg_parse( const UMessageFormat *fmt, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: int32_t *count, michael@0: UErrorCode *status, michael@0: ...); michael@0: michael@0: /** michael@0: * Parse a message. michael@0: * For numeric arguments, this function will always use doubles. Integer types michael@0: * should not be passed. michael@0: * This function is not able to parse all output from {@link #umsg_format }. michael@0: * @param fmt The formatter to use michael@0: * @param source The text to parse. michael@0: * @param sourceLength The length of source, or -1 if null-terminated. michael@0: * @param count Output param to receive number of elements returned. michael@0: * @param ap A variable-length argument list containing the arguments michael@0: * @param status A pointer to an UErrorCode to receive any errors michael@0: * specified in pattern. michael@0: * @see u_formatMessage michael@0: * @stable ICU 2.0 michael@0: */ michael@0: U_STABLE void U_EXPORT2 michael@0: umsg_vparse(const UMessageFormat *fmt, michael@0: const UChar *source, michael@0: int32_t sourceLength, michael@0: int32_t *count, michael@0: va_list ap, michael@0: UErrorCode *status); michael@0: michael@0: michael@0: /** michael@0: * Convert an 'apostrophe-friendly' pattern into a standard michael@0: * pattern. Standard patterns treat all apostrophes as michael@0: * quotes, which is problematic in some languages, e.g. michael@0: * French, where apostrophe is commonly used. This utility michael@0: * assumes that only an unpaired apostrophe immediately before michael@0: * a brace is a true quote. Other unpaired apostrophes are paired, michael@0: * and the resulting standard pattern string is returned. michael@0: * michael@0: *

Note it is not guaranteed that the returned pattern michael@0: * is indeed a valid pattern. The only effect is to convert michael@0: * between patterns having different quoting semantics. michael@0: * michael@0: * @param pattern the 'apostrophe-friendly' patttern to convert michael@0: * @param patternLength the length of pattern, or -1 if unknown and pattern is null-terminated michael@0: * @param dest the buffer for the result, or NULL if preflight only michael@0: * @param destCapacity the length of the buffer, or 0 if preflighting michael@0: * @param ec the error code michael@0: * @return the length of the resulting text, not including trailing null michael@0: * if buffer has room for the trailing null, it is provided, otherwise michael@0: * not michael@0: * @stable ICU 3.4 michael@0: */ michael@0: U_STABLE int32_t U_EXPORT2 michael@0: umsg_autoQuoteApostrophe(const UChar* pattern, michael@0: int32_t patternLength, michael@0: UChar* dest, michael@0: int32_t destCapacity, michael@0: UErrorCode* ec); michael@0: michael@0: #endif /* #if !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif