umsg.h 24 KB

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