umsg.h 24 KB

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