umsg.h 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /********************************************************************
  4. * COPYRIGHT:
  5. * Copyright (c) 1997-2011, International Business Machines Corporation and
  6. * others. All Rights Reserved.
  7. * Copyright (C) 2010 , Yahoo! Inc.
  8. ********************************************************************
  9. *
  10. * file name: umsg.h
  11. * encoding: UTF-8
  12. * tab size: 8 (not used)
  13. * indentation:4
  14. *
  15. * Change history:
  16. *
  17. * 08/5/2001 Ram Added C wrappers for C++ API.
  18. ********************************************************************/
  19. #ifndef UMSG_H
  20. #define UMSG_H
  21. #include "unicode/utypes.h"
  22. #if !UCONFIG_NO_FORMATTING
  23. #include "unicode/uloc.h"
  24. #include "unicode/parseerr.h"
  25. #include <stdarg.h>
  26. #if U_SHOW_CPLUSPLUS_API
  27. #include "unicode/localpointer.h"
  28. #endif // U_SHOW_CPLUSPLUS_API
  29. /**
  30. * \file
  31. * \brief C API: MessageFormat
  32. *
  33. * <h2>MessageFormat C API </h2>
  34. *
  35. * <p>MessageFormat prepares strings for display to users,
  36. * with optional arguments (variables/placeholders).
  37. * The arguments can occur in any order, which is necessary for translation
  38. * into languages with different grammars.
  39. *
  40. * <p>The opaque UMessageFormat type is a thin C wrapper around
  41. * a C++ MessageFormat. It is constructed from a <em>pattern</em> string
  42. * with arguments in {curly braces} which will be replaced by formatted values.
  43. *
  44. * <p>Currently, the C API supports only numbered arguments.
  45. *
  46. * <p>For details about the pattern syntax and behavior,
  47. * especially about the ASCII apostrophe vs. the
  48. * real apostrophe (single quote) character \htmlonly&#x2019;\endhtmlonly (U+2019),
  49. * see the C++ MessageFormat class documentation.
  50. *
  51. * <p>Here are some examples of C API usage:
  52. * Example 1:
  53. * <pre>
  54. * \code
  55. * UChar *result, *tzID, *str;
  56. * UChar pattern[100];
  57. * int32_t resultLengthOut, resultlength;
  58. * UCalendar *cal;
  59. * UDate d1;
  60. * UDateFormat *def1;
  61. * UErrorCode status = U_ZERO_ERROR;
  62. *
  63. * str=(UChar*)malloc(sizeof(UChar) * (strlen("disturbance in force") +1));
  64. * u_uastrcpy(str, "disturbance in force");
  65. * tzID=(UChar*)malloc(sizeof(UChar) * 4);
  66. * u_uastrcpy(tzID, "PST");
  67. * cal=ucal_open(tzID, u_strlen(tzID), "en_US", UCAL_TRADITIONAL, &status);
  68. * ucal_setDateTime(cal, 1999, UCAL_MARCH, 18, 0, 0, 0, &status);
  69. * d1=ucal_getMillis(cal, &status);
  70. * u_uastrcpy(pattern, "On {0, date, long}, there was a {1} on planet {2,number,integer}");
  71. * resultlength=0;
  72. * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, d1, str, 7);
  73. * if(status==U_BUFFER_OVERFLOW_ERROR){
  74. * status=U_ZERO_ERROR;
  75. * resultlength=resultLengthOut+1;
  76. * result=(UChar*)realloc(result, sizeof(UChar) * resultlength);
  77. * u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, d1, str, 7);
  78. * }
  79. * printf("%s\n", austrdup(result) );//austrdup( a function used to convert UChar* to char*)
  80. * //output>: "On March 18, 1999, there was a disturbance in force on planet 7
  81. * \endcode
  82. * </pre>
  83. * Typically, the message format will come from resources, and the
  84. * arguments will be dynamically set at runtime.
  85. * <P>
  86. * Example 2:
  87. * <pre>
  88. * \code
  89. * UChar* str;
  90. * UErrorCode status = U_ZERO_ERROR;
  91. * UChar *result;
  92. * UChar pattern[100];
  93. * int32_t resultlength, resultLengthOut, i;
  94. * double testArgs= { 100.0, 1.0, 0.0};
  95. *
  96. * str=(UChar*)malloc(sizeof(UChar) * 10);
  97. * u_uastrcpy(str, "MyDisk");
  98. * u_uastrcpy(pattern, "The disk {1} contains {0,choice,0#no files|1#one file|1<{0,number,integer} files}");
  99. * for(i=0; i<3; i++){
  100. * resultlength=0;
  101. * resultLengthOut=u_formatMessage( "en_US", pattern, u_strlen(pattern), NULL, resultlength, &status, testArgs[i], str);
  102. * if(status==U_BUFFER_OVERFLOW_ERROR){
  103. * status=U_ZERO_ERROR;
  104. * resultlength=resultLengthOut+1;
  105. * result=(UChar*)malloc(sizeof(UChar) * resultlength);
  106. * u_formatMessage( "en_US", pattern, u_strlen(pattern), result, resultlength, &status, testArgs[i], str);
  107. * }
  108. * printf("%s\n", austrdup(result) ); //austrdup( a function used to convert UChar* to char*)
  109. * free(result);
  110. * }
  111. * // output, with different testArgs:
  112. * // output: The disk "MyDisk" contains 100 files.
  113. * // output: The disk "MyDisk" contains one file.
  114. * // output: The disk "MyDisk" contains no files.
  115. * \endcode
  116. * </pre>
  117. *
  118. *
  119. * Example 3:
  120. * <pre>
  121. * \code
  122. * UChar* str;
  123. * UChar* str1;
  124. * UErrorCode status = U_ZERO_ERROR;
  125. * UChar *result;
  126. * UChar pattern[100];
  127. * UChar expected[100];
  128. * int32_t resultlength,resultLengthOut;
  129. * str=(UChar*)malloc(sizeof(UChar) * 25);
  130. * u_uastrcpy(str, "Kirti");
  131. * str1=(UChar*)malloc(sizeof(UChar) * 25);
  132. * u_uastrcpy(str1, "female");
  133. * log_verbose("Testing message format with Select test #1\n:");
  134. * u_uastrcpy(pattern, "{0} est {1, select, female {all\\u00E9e} other {all\\u00E9}} \\u00E0 Paris.");
  135. * u_uastrcpy(expected, "Kirti est all\\u00E9e \\u00E0 Paris.");
  136. * resultlength=0;
  137. * resultLengthOut=u_formatMessage( "fr", pattern, u_strlen(pattern), NULL, resultlength, &status, str , str1);
  138. * if(status==U_BUFFER_OVERFLOW_ERROR)
  139. * {
  140. * status=U_ZERO_ERROR;
  141. * resultlength=resultLengthOut+1;
  142. * result=(UChar*)malloc(sizeof(UChar) * resultlength);
  143. * u_formatMessage( "fr", pattern, u_strlen(pattern), result, resultlength, &status, str , str1);
  144. * if(u_strcmp(result, expected)==0)
  145. * log_verbose("PASS: MessagFormat successful on Select test#1\n");
  146. * else{
  147. * log_err("FAIL: Error in MessageFormat on Select test#1\n GOT %s EXPECTED %s\n", austrdup(result),
  148. * austrdup(expected) );
  149. * }
  150. * free(result);
  151. * }
  152. * \endcode
  153. * </pre>
  154. */
  155. /**
  156. * Format a message for a locale.
  157. * This function may perform re-ordering of the arguments depending on the
  158. * locale. For all numeric arguments, double is assumed unless the type is
  159. * explicitly integer. All choice format arguments must be of type double.
  160. * @param locale The locale for which the message will be formatted
  161. * @param pattern The pattern specifying the message's format
  162. * @param patternLength The length of pattern
  163. * @param result A pointer to a buffer to receive the formatted message.
  164. * @param resultLength The maximum size of result.
  165. * @param status A pointer to an UErrorCode to receive any errors
  166. * @param ... A variable-length argument list containing the arguments specified
  167. * in pattern.
  168. * @return The total buffer size needed; if greater than resultLength, the
  169. * output was truncated.
  170. * @see u_parseMessage
  171. * @stable ICU 2.0
  172. */
  173. U_CAPI int32_t U_EXPORT2
  174. u_formatMessage(const char *locale,
  175. const UChar *pattern,
  176. int32_t patternLength,
  177. UChar *result,
  178. int32_t resultLength,
  179. UErrorCode *status,
  180. ...);
  181. /**
  182. * Format a message for a locale.
  183. * This function may perform re-ordering of the arguments depending on the
  184. * locale. For all numeric arguments, double is assumed unless the type is
  185. * explicitly integer. All choice format arguments must be of type double.
  186. * @param locale The locale for which the message will be formatted
  187. * @param pattern The pattern specifying the message's format
  188. * @param patternLength The length of pattern
  189. * @param result A pointer to a buffer to receive the formatted message.
  190. * @param resultLength The maximum size of result.
  191. * @param ap A variable-length argument list containing the arguments specified
  192. * @param status A pointer to an UErrorCode to receive any errors
  193. * in pattern.
  194. * @return The total buffer size needed; if greater than resultLength, the
  195. * output was truncated.
  196. * @see u_parseMessage
  197. * @stable ICU 2.0
  198. */
  199. U_CAPI int32_t U_EXPORT2
  200. u_vformatMessage( const char *locale,
  201. const UChar *pattern,
  202. int32_t patternLength,
  203. UChar *result,
  204. int32_t resultLength,
  205. va_list ap,
  206. UErrorCode *status);
  207. /**
  208. * Parse a message.
  209. * For numeric arguments, this function will always use doubles. Integer types
  210. * should not be passed.
  211. * This function is not able to parse all output from {@link #u_formatMessage }.
  212. * @param locale The locale for which the message is formatted
  213. * @param pattern The pattern specifying the message's format
  214. * @param patternLength The length of pattern
  215. * @param source The text to parse.
  216. * @param sourceLength The length of source, or -1 if null-terminated.
  217. * @param status A pointer to an UErrorCode to receive any errors
  218. * @param ... A variable-length argument list containing the arguments
  219. * specified in pattern.
  220. * @see u_formatMessage
  221. * @stable ICU 2.0
  222. */
  223. U_CAPI void U_EXPORT2
  224. u_parseMessage( const char *locale,
  225. const UChar *pattern,
  226. int32_t patternLength,
  227. const UChar *source,
  228. int32_t sourceLength,
  229. UErrorCode *status,
  230. ...);
  231. /**
  232. * Parse a message.
  233. * For numeric arguments, this function will always use doubles. Integer types
  234. * should not be passed.
  235. * This function is not able to parse all output from {@link #u_formatMessage }.
  236. * @param locale The locale for which the message is formatted
  237. * @param pattern The pattern specifying the message's format
  238. * @param patternLength The length of pattern
  239. * @param source The text to parse.
  240. * @param sourceLength The length of source, or -1 if null-terminated.
  241. * @param ap A variable-length argument list containing the arguments
  242. * @param status A pointer to an UErrorCode to receive any errors
  243. * specified in pattern.
  244. * @see u_formatMessage
  245. * @stable ICU 2.0
  246. */
  247. U_CAPI void U_EXPORT2
  248. u_vparseMessage(const char *locale,
  249. const UChar *pattern,
  250. int32_t patternLength,
  251. const UChar *source,
  252. int32_t sourceLength,
  253. va_list ap,
  254. UErrorCode *status);
  255. /**
  256. * Format a message for a locale.
  257. * This function may perform re-ordering of the arguments depending on the
  258. * locale. For all numeric arguments, double is assumed unless the type is
  259. * explicitly integer. All choice format arguments must be of type double.
  260. * @param locale The locale for which the message will be formatted
  261. * @param pattern The pattern specifying the message's format
  262. * @param patternLength The length of pattern
  263. * @param result A pointer to a buffer to receive the formatted message.
  264. * @param resultLength The maximum size of result.
  265. * @param status A pointer to an UErrorCode to receive any errors
  266. * @param ... A variable-length argument list containing the arguments specified
  267. * in pattern.
  268. * @param parseError A pointer to UParseError to receive information about errors
  269. * occurred during parsing.
  270. * @return The total buffer size needed; if greater than resultLength, the
  271. * output was truncated.
  272. * @see u_parseMessage
  273. * @stable ICU 2.0
  274. */
  275. U_CAPI int32_t U_EXPORT2
  276. u_formatMessageWithError( const char *locale,
  277. const UChar *pattern,
  278. int32_t patternLength,
  279. UChar *result,
  280. int32_t resultLength,
  281. UParseError *parseError,
  282. UErrorCode *status,
  283. ...);
  284. /**
  285. * Format a message for a locale.
  286. * This function may perform re-ordering of the arguments depending on the
  287. * locale. For all numeric arguments, double is assumed unless the type is
  288. * explicitly integer. All choice format arguments must be of type double.
  289. * @param locale The locale for which the message will be formatted
  290. * @param pattern The pattern specifying the message's format
  291. * @param patternLength The length of pattern
  292. * @param result A pointer to a buffer to receive the formatted message.
  293. * @param resultLength The maximum size of result.
  294. * @param parseError A pointer to UParseError to receive information about errors
  295. * occurred during parsing.
  296. * @param ap A variable-length argument list containing the arguments specified
  297. * @param status A pointer to an UErrorCode to receive any errors
  298. * in pattern.
  299. * @return The total buffer size needed; if greater than resultLength, the
  300. * output was truncated.
  301. * @stable ICU 2.0
  302. */
  303. U_CAPI int32_t U_EXPORT2
  304. u_vformatMessageWithError( const char *locale,
  305. const UChar *pattern,
  306. int32_t patternLength,
  307. UChar *result,
  308. int32_t resultLength,
  309. UParseError* parseError,
  310. va_list ap,
  311. UErrorCode *status);
  312. /**
  313. * Parse a message.
  314. * For numeric arguments, this function will always use doubles. Integer types
  315. * should not be passed.
  316. * This function is not able to parse all output from {@link #u_formatMessage }.
  317. * @param locale The locale for which the message is formatted
  318. * @param pattern The pattern specifying the message's format
  319. * @param patternLength The length of pattern
  320. * @param source The text to parse.
  321. * @param sourceLength The length of source, or -1 if null-terminated.
  322. * @param parseError A pointer to UParseError to receive information about errors
  323. * occurred during parsing.
  324. * @param status A pointer to an UErrorCode to receive any errors
  325. * @param ... A variable-length argument list containing the arguments
  326. * specified in pattern.
  327. * @see u_formatMessage
  328. * @stable ICU 2.0
  329. */
  330. U_CAPI void U_EXPORT2
  331. u_parseMessageWithError(const char *locale,
  332. const UChar *pattern,
  333. int32_t patternLength,
  334. const UChar *source,
  335. int32_t sourceLength,
  336. UParseError *parseError,
  337. UErrorCode *status,
  338. ...);
  339. /**
  340. * Parse a message.
  341. * For numeric arguments, this function will always use doubles. Integer types
  342. * should not be passed.
  343. * This function is not able to parse all output from {@link #u_formatMessage }.
  344. * @param locale The locale for which the message is formatted
  345. * @param pattern The pattern specifying the message's format
  346. * @param patternLength The length of pattern
  347. * @param source The text to parse.
  348. * @param sourceLength The length of source, or -1 if null-terminated.
  349. * @param ap A variable-length argument list containing the arguments
  350. * @param parseError A pointer to UParseError to receive information about errors
  351. * occurred during parsing.
  352. * @param status A pointer to an UErrorCode to receive any errors
  353. * specified in pattern.
  354. * @see u_formatMessage
  355. * @stable ICU 2.0
  356. */
  357. U_CAPI void U_EXPORT2
  358. u_vparseMessageWithError(const char *locale,
  359. const UChar *pattern,
  360. int32_t patternLength,
  361. const UChar *source,
  362. int32_t sourceLength,
  363. va_list ap,
  364. UParseError *parseError,
  365. UErrorCode* status);
  366. /*----------------------- New experimental API --------------------------- */
  367. /**
  368. * The message format object
  369. * @stable ICU 2.0
  370. */
  371. typedef void* UMessageFormat;
  372. /**
  373. * Open a message formatter with given pattern and for the given locale.
  374. * @param pattern A pattern specifying the format to use.
  375. * @param patternLength Length of the pattern to use
  376. * @param locale The locale for which the messages are formatted.
  377. * @param parseError A pointer to UParseError struct to receive any errors
  378. * occurred during parsing. Can be NULL.
  379. * @param status A pointer to an UErrorCode to receive any errors.
  380. * @return A pointer to a UMessageFormat to use for formatting
  381. * messages, or 0 if an error occurred.
  382. * @stable ICU 2.0
  383. */
  384. U_CAPI UMessageFormat* U_EXPORT2
  385. umsg_open( const UChar *pattern,
  386. int32_t patternLength,
  387. const char *locale,
  388. UParseError *parseError,
  389. UErrorCode *status);
  390. /**
  391. * Close a UMessageFormat.
  392. * Once closed, a UMessageFormat may no longer be used.
  393. * @param format The formatter to close.
  394. * @stable ICU 2.0
  395. */
  396. U_CAPI void U_EXPORT2
  397. umsg_close(UMessageFormat* format);
  398. #if U_SHOW_CPLUSPLUS_API
  399. U_NAMESPACE_BEGIN
  400. /**
  401. * \class LocalUMessageFormatPointer
  402. * "Smart pointer" class, closes a UMessageFormat via umsg_close().
  403. * For most methods see the LocalPointerBase base class.
  404. *
  405. * @see LocalPointerBase
  406. * @see LocalPointer
  407. * @stable ICU 4.4
  408. */
  409. U_DEFINE_LOCAL_OPEN_POINTER(LocalUMessageFormatPointer, UMessageFormat, umsg_close);
  410. U_NAMESPACE_END
  411. #endif
  412. /**
  413. * Open a copy of a UMessageFormat.
  414. * This function performs a deep copy.
  415. * @param fmt The formatter to copy
  416. * @param status A pointer to an UErrorCode to receive any errors.
  417. * @return A pointer to a UDateFormat identical to fmt.
  418. * @stable ICU 2.0
  419. */
  420. U_CAPI UMessageFormat U_EXPORT2
  421. umsg_clone(const UMessageFormat *fmt,
  422. UErrorCode *status);
  423. /**
  424. * Sets the locale. This locale is used for fetching default number or date
  425. * format information.
  426. * @param fmt The formatter to set
  427. * @param locale The locale the formatter should use.
  428. * @stable ICU 2.0
  429. */
  430. U_CAPI void U_EXPORT2
  431. umsg_setLocale(UMessageFormat *fmt,
  432. const char* locale);
  433. /**
  434. * Gets the locale. This locale is used for fetching default number or date
  435. * format information.
  436. * @param fmt The formatter to querry
  437. * @return the locale.
  438. * @stable ICU 2.0
  439. */
  440. U_CAPI const char* U_EXPORT2
  441. umsg_getLocale(const UMessageFormat *fmt);
  442. /**
  443. * Sets the pattern.
  444. * @param fmt The formatter to use
  445. * @param pattern The pattern to be applied.
  446. * @param patternLength Length of the pattern to use
  447. * @param parseError Struct to receive information on position
  448. * of error if an error is encountered.Can be NULL.
  449. * @param status Output param set to success/failure code on
  450. * exit. If the pattern is invalid, this will be
  451. * set to a failure result.
  452. * @stable ICU 2.0
  453. */
  454. U_CAPI void U_EXPORT2
  455. umsg_applyPattern( UMessageFormat *fmt,
  456. const UChar* pattern,
  457. int32_t patternLength,
  458. UParseError* parseError,
  459. UErrorCode* status);
  460. /**
  461. * Gets the pattern.
  462. * @param fmt The formatter to use
  463. * @param result A pointer to a buffer to receive the pattern.
  464. * @param resultLength The maximum size of result.
  465. * @param status Output param set to success/failure code on
  466. * exit. If the pattern is invalid, this will be
  467. * set to a failure result.
  468. * @return the pattern of the format
  469. * @stable ICU 2.0
  470. */
  471. U_CAPI int32_t U_EXPORT2
  472. umsg_toPattern(const UMessageFormat *fmt,
  473. UChar* result,
  474. int32_t resultLength,
  475. UErrorCode* status);
  476. /**
  477. * Format a message for a locale.
  478. * This function may perform re-ordering of the arguments depending on the
  479. * locale. For all numeric arguments, double is assumed unless the type is
  480. * explicitly integer. All choice format arguments must be of type double.
  481. * @param fmt The formatter to use
  482. * @param result A pointer to a buffer to receive the formatted message.
  483. * @param resultLength The maximum size of result.
  484. * @param status A pointer to an UErrorCode to receive any errors
  485. * @param ... A variable-length argument list containing the arguments
  486. * specified in pattern.
  487. * @return The total buffer size needed; if greater than resultLength,
  488. * the output was truncated.
  489. * @stable ICU 2.0
  490. */
  491. U_CAPI int32_t U_EXPORT2
  492. umsg_format( const UMessageFormat *fmt,
  493. UChar *result,
  494. int32_t resultLength,
  495. UErrorCode *status,
  496. ...);
  497. /**
  498. * Format a message for a locale.
  499. * This function may perform re-ordering of the arguments depending on the
  500. * locale. For all numeric arguments, double is assumed unless the type is
  501. * explicitly integer. All choice format arguments must be of type double.
  502. * @param fmt The formatter to use
  503. * @param result A pointer to a buffer to receive the formatted message.
  504. * @param resultLength The maximum size of result.
  505. * @param ap A variable-length argument list containing the arguments
  506. * @param status A pointer to an UErrorCode to receive any errors
  507. * specified in pattern.
  508. * @return The total buffer size needed; if greater than resultLength,
  509. * the output was truncated.
  510. * @stable ICU 2.0
  511. */
  512. U_CAPI int32_t U_EXPORT2
  513. umsg_vformat( const UMessageFormat *fmt,
  514. UChar *result,
  515. int32_t resultLength,
  516. va_list ap,
  517. UErrorCode *status);
  518. /**
  519. * Parse a message.
  520. * For numeric arguments, this function will always use doubles. Integer types
  521. * should not be passed.
  522. * This function is not able to parse all output from {@link #umsg_format }.
  523. * @param fmt The formatter to use
  524. * @param source The text to parse.
  525. * @param sourceLength The length of source, or -1 if null-terminated.
  526. * @param count Output param to receive number of elements returned.
  527. * @param status A pointer to an UErrorCode to receive any errors
  528. * @param ... A variable-length argument list containing the arguments
  529. * specified in pattern.
  530. * @stable ICU 2.0
  531. */
  532. U_CAPI void U_EXPORT2
  533. umsg_parse( const UMessageFormat *fmt,
  534. const UChar *source,
  535. int32_t sourceLength,
  536. int32_t *count,
  537. UErrorCode *status,
  538. ...);
  539. /**
  540. * Parse a message.
  541. * For numeric arguments, this function will always use doubles. Integer types
  542. * should not be passed.
  543. * This function is not able to parse all output from {@link #umsg_format }.
  544. * @param fmt The formatter to use
  545. * @param source The text to parse.
  546. * @param sourceLength The length of source, or -1 if null-terminated.
  547. * @param count Output param to receive number of elements returned.
  548. * @param ap A variable-length argument list containing the arguments
  549. * @param status A pointer to an UErrorCode to receive any errors
  550. * specified in pattern.
  551. * @see u_formatMessage
  552. * @stable ICU 2.0
  553. */
  554. U_CAPI void U_EXPORT2
  555. umsg_vparse(const UMessageFormat *fmt,
  556. const UChar *source,
  557. int32_t sourceLength,
  558. int32_t *count,
  559. va_list ap,
  560. UErrorCode *status);
  561. /**
  562. * Convert an 'apostrophe-friendly' pattern into a standard
  563. * pattern. Standard patterns treat all apostrophes as
  564. * quotes, which is problematic in some languages, e.g.
  565. * French, where apostrophe is commonly used. This utility
  566. * assumes that only an unpaired apostrophe immediately before
  567. * a brace is a true quote. Other unpaired apostrophes are paired,
  568. * and the resulting standard pattern string is returned.
  569. *
  570. * <p><b>Note</b> it is not guaranteed that the returned pattern
  571. * is indeed a valid pattern. The only effect is to convert
  572. * between patterns having different quoting semantics.
  573. *
  574. * @param pattern the 'apostrophe-friendly' patttern to convert
  575. * @param patternLength the length of pattern, or -1 if unknown and pattern is null-terminated
  576. * @param dest the buffer for the result, or NULL if preflight only
  577. * @param destCapacity the length of the buffer, or 0 if preflighting
  578. * @param ec the error code
  579. * @return the length of the resulting text, not including trailing null
  580. * if buffer has room for the trailing null, it is provided, otherwise
  581. * not
  582. * @stable ICU 3.4
  583. */
  584. U_CAPI int32_t U_EXPORT2
  585. umsg_autoQuoteApostrophe(const UChar* pattern,
  586. int32_t patternLength,
  587. UChar* dest,
  588. int32_t destCapacity,
  589. UErrorCode* ec);
  590. #endif /* #if !UCONFIG_NO_FORMATTING */
  591. #endif