uloc.h 45 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. /*
  2. **********************************************************************
  3. * Copyright (C) 1997-2010, International Business Machines
  4. * Corporation and others. All Rights Reserved.
  5. **********************************************************************
  6. *
  7. * File ULOC.H
  8. *
  9. * Modification History:
  10. *
  11. * Date Name Description
  12. * 04/01/97 aliu Creation.
  13. * 08/22/98 stephen JDK 1.2 sync.
  14. * 12/08/98 rtg New C API for Locale
  15. * 03/30/99 damiba overhaul
  16. * 03/31/99 helena Javadoc for uloc functions.
  17. * 04/15/99 Madhu Updated Javadoc
  18. ********************************************************************************
  19. */
  20. #ifndef ULOC_H
  21. #define ULOC_H
  22. #include "unicode/utypes.h"
  23. #include "unicode/uenum.h"
  24. /**
  25. * \file
  26. * \brief C API: Locale
  27. *
  28. * <h2> ULoc C API for Locale </h2>
  29. * A <code>Locale</code> represents a specific geographical, political,
  30. * or cultural region. An operation that requires a <code>Locale</code> to perform
  31. * its task is called <em>locale-sensitive</em> and uses the <code>Locale</code>
  32. * to tailor information for the user. For example, displaying a number
  33. * is a locale-sensitive operation--the number should be formatted
  34. * according to the customs/conventions of the user's native country,
  35. * region, or culture. In the C APIs, a locales is simply a const char string.
  36. *
  37. * <P>
  38. * You create a <code>Locale</code> with one of the three options listed below.
  39. * Each of the component is separated by '_' in the locale string.
  40. * \htmlonly<blockquote>\endhtmlonly
  41. * <pre>
  42. * \code
  43. * newLanguage
  44. *
  45. * newLanguage + newCountry
  46. *
  47. * newLanguage + newCountry + newVariant
  48. * \endcode
  49. * </pre>
  50. * \htmlonly</blockquote>\endhtmlonly
  51. * The first option is a valid <STRONG>ISO
  52. * Language Code.</STRONG> These codes are the lower-case two-letter
  53. * codes as defined by ISO-639.
  54. * You can find a full list of these codes at a number of sites, such as:
  55. * <BR><a href ="http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt">
  56. * http://www.ics.uci.edu/pub/ietf/http/related/iso639.txt</a>
  57. *
  58. * <P>
  59. * The second option includes an additonal <STRONG>ISO Country
  60. * Code.</STRONG> These codes are the upper-case two-letter codes
  61. * as defined by ISO-3166.
  62. * You can find a full list of these codes at a number of sites, such as:
  63. * <BR><a href="http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html">
  64. * http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html</a>
  65. *
  66. * <P>
  67. * The third option requires another additonal information--the
  68. * <STRONG>Variant.</STRONG>
  69. * The Variant codes are vendor and browser-specific.
  70. * For example, use WIN for Windows, MAC for Macintosh, and POSIX for POSIX.
  71. * Where there are two variants, separate them with an underscore, and
  72. * put the most important one first. For
  73. * example, a Traditional Spanish collation might be referenced, with
  74. * "ES", "ES", "Traditional_WIN".
  75. *
  76. * <P>
  77. * Because a <code>Locale</code> is just an identifier for a region,
  78. * no validity check is performed when you specify a <code>Locale</code>.
  79. * If you want to see whether particular resources are available for the
  80. * <code>Locale</code> you asked for, you must query those resources. For
  81. * example, ask the <code>UNumberFormat</code> for the locales it supports
  82. * using its <code>getAvailable</code> method.
  83. * <BR><STRONG>Note:</STRONG> When you ask for a resource for a particular
  84. * locale, you get back the best available match, not necessarily
  85. * precisely what you asked for. For more information, look at
  86. * <code>UResourceBundle</code>.
  87. *
  88. * <P>
  89. * The <code>Locale</code> provides a number of convenient constants
  90. * that you can use to specify the commonly used
  91. * locales. For example, the following refers to a locale
  92. * for the United States:
  93. * \htmlonly<blockquote>\endhtmlonly
  94. * <pre>
  95. * \code
  96. * ULOC_US
  97. * \endcode
  98. * </pre>
  99. * \htmlonly</blockquote>\endhtmlonly
  100. *
  101. * <P>
  102. * Once you've specified a locale you can query it for information about
  103. * itself. Use <code>uloc_getCountry</code> to get the ISO Country Code and
  104. * <code>uloc_getLanguage</code> to get the ISO Language Code. You can
  105. * use <code>uloc_getDisplayCountry</code> to get the
  106. * name of the country suitable for displaying to the user. Similarly,
  107. * you can use <code>uloc_getDisplayLanguage</code> to get the name of
  108. * the language suitable for displaying to the user. Interestingly,
  109. * the <code>uloc_getDisplayXXX</code> methods are themselves locale-sensitive
  110. * and have two versions: one that uses the default locale and one
  111. * that takes a locale as an argument and displays the name or country in
  112. * a language appropriate to that locale.
  113. *
  114. * <P>
  115. * The ICU provides a number of services that perform locale-sensitive
  116. * operations. For example, the <code>unum_xxx</code> functions format
  117. * numbers, currency, or percentages in a locale-sensitive manner.
  118. * </P>
  119. * \htmlonly<blockquote>\endhtmlonly
  120. * <pre>
  121. * \code
  122. * UErrorCode success = U_ZERO_ERROR;
  123. * UNumberFormat *nf;
  124. * const char* myLocale = "fr_FR";
  125. *
  126. * nf = unum_open( UNUM_DEFAULT, NULL, success );
  127. * unum_close(nf);
  128. * nf = unum_open( UNUM_CURRENCY, NULL, success );
  129. * unum_close(nf);
  130. * nf = unum_open( UNUM_PERCENT, NULL, success );
  131. * unum_close(nf);
  132. * \endcode
  133. * </pre>
  134. * \htmlonly</blockquote>\endhtmlonly
  135. * Each of these methods has two variants; one with an explicit locale
  136. * and one without; the latter using the default locale.
  137. * \htmlonly<blockquote>\endhtmlonly
  138. * <pre>
  139. * \code
  140. *
  141. * nf = unum_open( UNUM_DEFAULT, myLocale, success );
  142. * unum_close(nf);
  143. * nf = unum_open( UNUM_CURRENCY, myLocale, success );
  144. * unum_close(nf);
  145. * nf = unum_open( UNUM_PERCENT, myLocale, success );
  146. * unum_close(nf);
  147. * \endcode
  148. * </pre>
  149. * \htmlonly</blockquote>\endhtmlonly
  150. * A <code>Locale</code> is the mechanism for identifying the kind of services
  151. * (<code>UNumberFormat</code>) that you would like to get. The locale is
  152. * <STRONG>just</STRONG> a mechanism for identifying these services.
  153. *
  154. * <P>
  155. * Each international serivce that performs locale-sensitive operations
  156. * allows you
  157. * to get all the available objects of that type. You can sift
  158. * through these objects by language, country, or variant,
  159. * and use the display names to present a menu to the user.
  160. * For example, you can create a menu of all the collation objects
  161. * suitable for a given language. Such classes implement these
  162. * three class methods:
  163. * \htmlonly<blockquote>\endhtmlonly
  164. * <pre>
  165. * \code
  166. * const char* uloc_getAvailable(int32_t index);
  167. * int32_t uloc_countAvailable();
  168. * int32_t
  169. * uloc_getDisplayName(const char* localeID,
  170. * const char* inLocaleID,
  171. * UChar* result,
  172. * int32_t maxResultSize,
  173. * UErrorCode* err);
  174. *
  175. * \endcode
  176. * </pre>
  177. * \htmlonly</blockquote>\endhtmlonly
  178. * <P>
  179. * Concerning POSIX/RFC1766 Locale IDs,
  180. * the getLanguage/getCountry/getVariant/getName functions do understand
  181. * the POSIX type form of language_COUNTRY.ENCODING\@VARIANT
  182. * and if there is not an ICU-stype variant, uloc_getVariant() for example
  183. * will return the one listed after the \@at sign. As well, the hyphen
  184. * "-" is recognized as a country/variant separator similarly to RFC1766.
  185. * So for example, "en-us" will be interpreted as en_US.
  186. * As a result, uloc_getName() is far from a no-op, and will have the
  187. * effect of converting POSIX/RFC1766 IDs into ICU form, although it does
  188. * NOT map any of the actual codes (i.e. russian->ru) in any way.
  189. * Applications should call uloc_getName() at the point where a locale ID
  190. * is coming from an external source (user entry, OS, web browser)
  191. * and pass the resulting string to other ICU functions. For example,
  192. * don't use de-de\@EURO as an argument to resourcebundle.
  193. *
  194. * @see UResourceBundle
  195. */
  196. /** Useful constant for this language. @stable ICU 2.0 */
  197. #define ULOC_CHINESE "zh"
  198. /** Useful constant for this language. @stable ICU 2.0 */
  199. #define ULOC_ENGLISH "en"
  200. /** Useful constant for this language. @stable ICU 2.0 */
  201. #define ULOC_FRENCH "fr"
  202. /** Useful constant for this language. @stable ICU 2.0 */
  203. #define ULOC_GERMAN "de"
  204. /** Useful constant for this language. @stable ICU 2.0 */
  205. #define ULOC_ITALIAN "it"
  206. /** Useful constant for this language. @stable ICU 2.0 */
  207. #define ULOC_JAPANESE "ja"
  208. /** Useful constant for this language. @stable ICU 2.0 */
  209. #define ULOC_KOREAN "ko"
  210. /** Useful constant for this language. @stable ICU 2.0 */
  211. #define ULOC_SIMPLIFIED_CHINESE "zh_CN"
  212. /** Useful constant for this language. @stable ICU 2.0 */
  213. #define ULOC_TRADITIONAL_CHINESE "zh_TW"
  214. /** Useful constant for this country/region. @stable ICU 2.0 */
  215. #define ULOC_CANADA "en_CA"
  216. /** Useful constant for this country/region. @stable ICU 2.0 */
  217. #define ULOC_CANADA_FRENCH "fr_CA"
  218. /** Useful constant for this country/region. @stable ICU 2.0 */
  219. #define ULOC_CHINA "zh_CN"
  220. /** Useful constant for this country/region. @stable ICU 2.0 */
  221. #define ULOC_PRC "zh_CN"
  222. /** Useful constant for this country/region. @stable ICU 2.0 */
  223. #define ULOC_FRANCE "fr_FR"
  224. /** Useful constant for this country/region. @stable ICU 2.0 */
  225. #define ULOC_GERMANY "de_DE"
  226. /** Useful constant for this country/region. @stable ICU 2.0 */
  227. #define ULOC_ITALY "it_IT"
  228. /** Useful constant for this country/region. @stable ICU 2.0 */
  229. #define ULOC_JAPAN "ja_JP"
  230. /** Useful constant for this country/region. @stable ICU 2.0 */
  231. #define ULOC_KOREA "ko_KR"
  232. /** Useful constant for this country/region. @stable ICU 2.0 */
  233. #define ULOC_TAIWAN "zh_TW"
  234. /** Useful constant for this country/region. @stable ICU 2.0 */
  235. #define ULOC_UK "en_GB"
  236. /** Useful constant for this country/region. @stable ICU 2.0 */
  237. #define ULOC_US "en_US"
  238. /**
  239. * Useful constant for the maximum size of the language part of a locale ID.
  240. * (including the terminating NULL).
  241. * @stable ICU 2.0
  242. */
  243. #define ULOC_LANG_CAPACITY 12
  244. /**
  245. * Useful constant for the maximum size of the country part of a locale ID
  246. * (including the terminating NULL).
  247. * @stable ICU 2.0
  248. */
  249. #define ULOC_COUNTRY_CAPACITY 4
  250. /**
  251. * Useful constant for the maximum size of the whole locale ID
  252. * (including the terminating NULL and all keywords).
  253. * @stable ICU 2.0
  254. */
  255. #define ULOC_FULLNAME_CAPACITY 157
  256. /**
  257. * Useful constant for the maximum size of the script part of a locale ID
  258. * (including the terminating NULL).
  259. * @stable ICU 2.8
  260. */
  261. #define ULOC_SCRIPT_CAPACITY 6
  262. /**
  263. * Useful constant for the maximum size of keywords in a locale
  264. * @stable ICU 2.8
  265. */
  266. #define ULOC_KEYWORDS_CAPACITY 50
  267. /**
  268. * Useful constant for the maximum total size of keywords and their values in a locale
  269. * @stable ICU 2.8
  270. */
  271. #define ULOC_KEYWORD_AND_VALUES_CAPACITY 100
  272. /**
  273. * Invariant character separating keywords from the locale string
  274. * @stable ICU 2.8
  275. */
  276. #define ULOC_KEYWORD_SEPARATOR '@'
  277. /**
  278. * Unicode code point for '@' separating keywords from the locale string.
  279. * @see ULOC_KEYWORD_SEPARATOR
  280. * @draft ICU 4.6
  281. */
  282. #define ULOC_KEYWORD_SEPARATOR_UNICODE 0x40
  283. /**
  284. * Invariant character for assigning value to a keyword
  285. * @stable ICU 2.8
  286. */
  287. #define ULOC_KEYWORD_ASSIGN '='
  288. /**
  289. * Unicode code point for '=' for assigning value to a keyword.
  290. * @see ULOC_KEYWORD_ASSIGN
  291. * @draft ICU 4.6
  292. */
  293. #define ULOC_KEYWORD_ASSIGN_UNICODE 0x3D
  294. /**
  295. * Invariant character separating keywords
  296. * @stable ICU 2.8
  297. */
  298. #define ULOC_KEYWORD_ITEM_SEPARATOR ';'
  299. /**
  300. * Unicode code point for ';' separating keywords
  301. * @see ULOC_KEYWORD_ITEM_SEPARATOR
  302. * @draft ICU 4.6
  303. */
  304. #define ULOC_KEYWORD_ITEM_SEPARATOR_UNICODE 0x3B
  305. /**
  306. * Constants for *_getLocale()
  307. * Allow user to select whether she wants information on
  308. * requested, valid or actual locale.
  309. * For example, a collator for "en_US_CALIFORNIA" was
  310. * requested. In the current state of ICU (2.0),
  311. * the requested locale is "en_US_CALIFORNIA",
  312. * the valid locale is "en_US" (most specific locale supported by ICU)
  313. * and the actual locale is "root" (the collation data comes unmodified
  314. * from the UCA)
  315. * The locale is considered supported by ICU if there is a core ICU bundle
  316. * for that locale (although it may be empty).
  317. * @stable ICU 2.1
  318. */
  319. typedef enum {
  320. /** This is locale the data actually comes from
  321. * @stable ICU 2.1
  322. */
  323. ULOC_ACTUAL_LOCALE = 0,
  324. /** This is the most specific locale supported by ICU
  325. * @stable ICU 2.1
  326. */
  327. ULOC_VALID_LOCALE = 1,
  328. #ifndef U_HIDE_DEPRECATED_API
  329. /** This is the requested locale
  330. * @deprecated ICU 2.8
  331. */
  332. ULOC_REQUESTED_LOCALE = 2,
  333. #endif /* U_HIDE_DEPRECATED_API */
  334. ULOC_DATA_LOCALE_TYPE_LIMIT = 3
  335. } ULocDataLocaleType ;
  336. /**
  337. * Gets ICU's default locale.
  338. * The returned string is a snapshot in time, and will remain valid
  339. * and unchanged even when uloc_setDefault() is called.
  340. * The returned storage is owned by ICU, and must not be altered or deleted
  341. * by the caller.
  342. *
  343. * @return the ICU default locale
  344. * @system
  345. * @stable ICU 2.0
  346. */
  347. U_STABLE const char* U_EXPORT2
  348. uloc_getDefault(void);
  349. /**
  350. * Sets ICU's default locale.
  351. * By default (without calling this function), ICU's default locale will be based
  352. * on information obtained from the underlying system environment.
  353. * <p>
  354. * Changes to ICU's default locale do not propagate back to the
  355. * system environment.
  356. * <p>
  357. * Changes to ICU's default locale to not affect any ICU services that
  358. * may already be open based on the previous default locale value.
  359. *
  360. * @param localeID the new ICU default locale. A value of NULL will try to get
  361. * the system's default locale.
  362. * @param status the error information if the setting of default locale fails
  363. * @system
  364. * @stable ICU 2.0
  365. */
  366. U_STABLE void U_EXPORT2
  367. uloc_setDefault(const char* localeID,
  368. UErrorCode* status);
  369. /**
  370. * Gets the language code for the specified locale.
  371. *
  372. * @param localeID the locale to get the ISO language code with
  373. * @param language the language code for localeID
  374. * @param languageCapacity the size of the language buffer to store the
  375. * language code with
  376. * @param err error information if retrieving the language code failed
  377. * @return the actual buffer size needed for the language code. If it's greater
  378. * than languageCapacity, the returned language code will be truncated.
  379. * @stable ICU 2.0
  380. */
  381. U_STABLE int32_t U_EXPORT2
  382. uloc_getLanguage(const char* localeID,
  383. char* language,
  384. int32_t languageCapacity,
  385. UErrorCode* err);
  386. /**
  387. * Gets the script code for the specified locale.
  388. *
  389. * @param localeID the locale to get the ISO language code with
  390. * @param script the language code for localeID
  391. * @param scriptCapacity the size of the language buffer to store the
  392. * language code with
  393. * @param err error information if retrieving the language code failed
  394. * @return the actual buffer size needed for the language code. If it's greater
  395. * than scriptCapacity, the returned language code will be truncated.
  396. * @stable ICU 2.8
  397. */
  398. U_STABLE int32_t U_EXPORT2
  399. uloc_getScript(const char* localeID,
  400. char* script,
  401. int32_t scriptCapacity,
  402. UErrorCode* err);
  403. /**
  404. * Gets the country code for the specified locale.
  405. *
  406. * @param localeID the locale to get the country code with
  407. * @param country the country code for localeID
  408. * @param countryCapacity the size of the country buffer to store the
  409. * country code with
  410. * @param err error information if retrieving the country code failed
  411. * @return the actual buffer size needed for the country code. If it's greater
  412. * than countryCapacity, the returned country code will be truncated.
  413. * @stable ICU 2.0
  414. */
  415. U_STABLE int32_t U_EXPORT2
  416. uloc_getCountry(const char* localeID,
  417. char* country,
  418. int32_t countryCapacity,
  419. UErrorCode* err);
  420. /**
  421. * Gets the variant code for the specified locale.
  422. *
  423. * @param localeID the locale to get the variant code with
  424. * @param variant the variant code for localeID
  425. * @param variantCapacity the size of the variant buffer to store the
  426. * variant code with
  427. * @param err error information if retrieving the variant code failed
  428. * @return the actual buffer size needed for the variant code. If it's greater
  429. * than variantCapacity, the returned variant code will be truncated.
  430. * @stable ICU 2.0
  431. */
  432. U_STABLE int32_t U_EXPORT2
  433. uloc_getVariant(const char* localeID,
  434. char* variant,
  435. int32_t variantCapacity,
  436. UErrorCode* err);
  437. /**
  438. * Gets the full name for the specified locale.
  439. * Note: This has the effect of 'canonicalizing' the ICU locale ID to
  440. * a certain extent. Upper and lower case are set as needed.
  441. * It does NOT map aliased names in any way.
  442. * See the top of this header file.
  443. * This API supports preflighting.
  444. *
  445. * @param localeID the locale to get the full name with
  446. * @param name fill in buffer for the name without keywords.
  447. * @param nameCapacity capacity of the fill in buffer.
  448. * @param err error information if retrieving the full name failed
  449. * @return the actual buffer size needed for the full name. If it's greater
  450. * than nameCapacity, the returned full name will be truncated.
  451. * @stable ICU 2.0
  452. */
  453. U_STABLE int32_t U_EXPORT2
  454. uloc_getName(const char* localeID,
  455. char* name,
  456. int32_t nameCapacity,
  457. UErrorCode* err);
  458. /**
  459. * Gets the full name for the specified locale.
  460. * Note: This has the effect of 'canonicalizing' the string to
  461. * a certain extent. Upper and lower case are set as needed,
  462. * and if the components were in 'POSIX' format they are changed to
  463. * ICU format. It does NOT map aliased names in any way.
  464. * See the top of this header file.
  465. *
  466. * @param localeID the locale to get the full name with
  467. * @param name the full name for localeID
  468. * @param nameCapacity the size of the name buffer to store the
  469. * full name with
  470. * @param err error information if retrieving the full name failed
  471. * @return the actual buffer size needed for the full name. If it's greater
  472. * than nameCapacity, the returned full name will be truncated.
  473. * @stable ICU 2.8
  474. */
  475. U_STABLE int32_t U_EXPORT2
  476. uloc_canonicalize(const char* localeID,
  477. char* name,
  478. int32_t nameCapacity,
  479. UErrorCode* err);
  480. /**
  481. * Gets the ISO language code for the specified locale.
  482. *
  483. * @param localeID the locale to get the ISO language code with
  484. * @return language the ISO language code for localeID
  485. * @stable ICU 2.0
  486. */
  487. U_STABLE const char* U_EXPORT2
  488. uloc_getISO3Language(const char* localeID);
  489. /**
  490. * Gets the ISO country code for the specified locale.
  491. *
  492. * @param localeID the locale to get the ISO country code with
  493. * @return country the ISO country code for localeID
  494. * @stable ICU 2.0
  495. */
  496. U_STABLE const char* U_EXPORT2
  497. uloc_getISO3Country(const char* localeID);
  498. /**
  499. * Gets the Win32 LCID value for the specified locale.
  500. * If the ICU locale is not recognized by Windows, 0 will be returned.
  501. *
  502. * @param localeID the locale to get the Win32 LCID value with
  503. * @return country the Win32 LCID for localeID
  504. * @stable ICU 2.0
  505. */
  506. U_STABLE uint32_t U_EXPORT2
  507. uloc_getLCID(const char* localeID);
  508. /**
  509. * Gets the language name suitable for display for the specified locale.
  510. *
  511. * @param locale the locale to get the ISO language code with
  512. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  513. * if the locale's language code is "en", passing Locale::getFrench() for
  514. * inLocale would result in "Anglais", while passing Locale::getGerman()
  515. * for inLocale would result in "Englisch".
  516. * @param language the displayable language code for localeID
  517. * @param languageCapacity the size of the language buffer to store the
  518. * displayable language code with
  519. * @param status error information if retrieving the displayable language code failed
  520. * @return the actual buffer size needed for the displayable language code. If it's greater
  521. * than languageCapacity, the returned language code will be truncated.
  522. * @stable ICU 2.0
  523. */
  524. U_STABLE int32_t U_EXPORT2
  525. uloc_getDisplayLanguage(const char* locale,
  526. const char* displayLocale,
  527. UChar* language,
  528. int32_t languageCapacity,
  529. UErrorCode* status);
  530. /**
  531. * Gets the script name suitable for display for the specified locale.
  532. *
  533. * @param locale the locale to get the displayable script code with. NULL may be used to specify the default.
  534. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  535. * if the locale's language code is "en", passing Locale::getFrench() for
  536. * inLocale would result in "", while passing Locale::getGerman()
  537. * for inLocale would result in "". NULL may be used to specify the default.
  538. * @param script the displayable country code for localeID
  539. * @param scriptCapacity the size of the script buffer to store the
  540. * displayable script code with
  541. * @param status error information if retrieving the displayable script code failed
  542. * @return the actual buffer size needed for the displayable script code. If it's greater
  543. * than scriptCapacity, the returned displayable script code will be truncated.
  544. * @stable ICU 2.8
  545. */
  546. U_STABLE int32_t U_EXPORT2
  547. uloc_getDisplayScript(const char* locale,
  548. const char* displayLocale,
  549. UChar* script,
  550. int32_t scriptCapacity,
  551. UErrorCode* status);
  552. /**
  553. * Gets the country name suitable for display for the specified locale.
  554. *
  555. * @param locale the locale to get the displayable country code with. NULL may be used to specify the default.
  556. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  557. * if the locale's language code is "en", passing Locale::getFrench() for
  558. * inLocale would result in "Anglais", while passing Locale::getGerman()
  559. * for inLocale would result in "Englisch". NULL may be used to specify the default.
  560. * @param country the displayable country code for localeID
  561. * @param countryCapacity the size of the country buffer to store the
  562. * displayable country code with
  563. * @param status error information if retrieving the displayable country code failed
  564. * @return the actual buffer size needed for the displayable country code. If it's greater
  565. * than countryCapacity, the returned displayable country code will be truncated.
  566. * @stable ICU 2.0
  567. */
  568. U_STABLE int32_t U_EXPORT2
  569. uloc_getDisplayCountry(const char* locale,
  570. const char* displayLocale,
  571. UChar* country,
  572. int32_t countryCapacity,
  573. UErrorCode* status);
  574. /**
  575. * Gets the variant name suitable for display for the specified locale.
  576. *
  577. * @param locale the locale to get the displayable variant code with. NULL may be used to specify the default.
  578. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  579. * if the locale's language code is "en", passing Locale::getFrench() for
  580. * inLocale would result in "Anglais", while passing Locale::getGerman()
  581. * for inLocale would result in "Englisch". NULL may be used to specify the default.
  582. * @param variant the displayable variant code for localeID
  583. * @param variantCapacity the size of the variant buffer to store the
  584. * displayable variant code with
  585. * @param status error information if retrieving the displayable variant code failed
  586. * @return the actual buffer size needed for the displayable variant code. If it's greater
  587. * than variantCapacity, the returned displayable variant code will be truncated.
  588. * @stable ICU 2.0
  589. */
  590. U_STABLE int32_t U_EXPORT2
  591. uloc_getDisplayVariant(const char* locale,
  592. const char* displayLocale,
  593. UChar* variant,
  594. int32_t variantCapacity,
  595. UErrorCode* status);
  596. /**
  597. * Gets the keyword name suitable for display for the specified locale.
  598. * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
  599. * string for the keyword collation.
  600. * Usage:
  601. * <code>
  602. * UErrorCode status = U_ZERO_ERROR;
  603. * const char* keyword =NULL;
  604. * int32_t keywordLen = 0;
  605. * int32_t keywordCount = 0;
  606. * UChar displayKeyword[256];
  607. * int32_t displayKeywordLen = 0;
  608. * UEnumeration* keywordEnum = uloc_openKeywords("de_DE@collation=PHONEBOOK;calendar=TRADITIONAL", &status);
  609. * for(keywordCount = uenum_count(keywordEnum, &status); keywordCount > 0 ; keywordCount--){
  610. * if(U_FAILURE(status)){
  611. * ...something went wrong so handle the error...
  612. * break;
  613. * }
  614. * // the uenum_next returns NUL terminated string
  615. * keyword = uenum_next(keywordEnum, &keywordLen, &status);
  616. * displayKeywordLen = uloc_getDisplayKeyword(keyword, "en_US", displayKeyword, 256);
  617. * ... do something interesting .....
  618. * }
  619. * uenum_close(keywordEnum);
  620. * </code>
  621. * @param keyword The keyword whose display string needs to be returned.
  622. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  623. * if the locale's language code is "en", passing Locale::getFrench() for
  624. * inLocale would result in "Anglais", while passing Locale::getGerman()
  625. * for inLocale would result in "Englisch". NULL may be used to specify the default.
  626. * @param dest the buffer to which the displayable keyword should be written.
  627. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
  628. * dest may be NULL and the function will only return the length of the
  629. * result without writing any of the result string (pre-flighting).
  630. * @param status error information if retrieving the displayable string failed.
  631. * Should not be NULL and should not indicate failure on entry.
  632. * @return the actual buffer size needed for the displayable variant code.
  633. * @see #uloc_openKeywords
  634. * @stable ICU 2.8
  635. */
  636. U_STABLE int32_t U_EXPORT2
  637. uloc_getDisplayKeyword(const char* keyword,
  638. const char* displayLocale,
  639. UChar* dest,
  640. int32_t destCapacity,
  641. UErrorCode* status);
  642. /**
  643. * Gets the value of the keyword suitable for display for the specified locale.
  644. * E.g: for the locale string de_DE\@collation=PHONEBOOK, this API gets the display
  645. * string for PHONEBOOK, in the display locale, when "collation" is specified as the keyword.
  646. *
  647. * @param locale The locale to get the displayable variant code with. NULL may be used to specify the default.
  648. * @param keyword The keyword for whose value should be used.
  649. * @param displayLocale Specifies the locale to be used to display the name. In other words,
  650. * if the locale's language code is "en", passing Locale::getFrench() for
  651. * inLocale would result in "Anglais", while passing Locale::getGerman()
  652. * for inLocale would result in "Englisch". NULL may be used to specify the default.
  653. * @param dest the buffer to which the displayable keyword should be written.
  654. * @param destCapacity The size of the buffer (number of UChars). If it is 0, then
  655. * dest may be NULL and the function will only return the length of the
  656. * result without writing any of the result string (pre-flighting).
  657. * @param status error information if retrieving the displayable string failed.
  658. * Should not be NULL and must not indicate failure on entry.
  659. * @return the actual buffer size needed for the displayable variant code.
  660. * @stable ICU 2.8
  661. */
  662. U_STABLE int32_t U_EXPORT2
  663. uloc_getDisplayKeywordValue( const char* locale,
  664. const char* keyword,
  665. const char* displayLocale,
  666. UChar* dest,
  667. int32_t destCapacity,
  668. UErrorCode* status);
  669. /**
  670. * Gets the full name suitable for display for the specified locale.
  671. *
  672. * @param localeID the locale to get the displayable name with. NULL may be used to specify the default.
  673. * @param inLocaleID Specifies the locale to be used to display the name. In other words,
  674. * if the locale's language code is "en", passing Locale::getFrench() for
  675. * inLocale would result in "Anglais", while passing Locale::getGerman()
  676. * for inLocale would result in "Englisch". NULL may be used to specify the default.
  677. * @param result the displayable name for localeID
  678. * @param maxResultSize the size of the name buffer to store the
  679. * displayable full name with
  680. * @param err error information if retrieving the displayable name failed
  681. * @return the actual buffer size needed for the displayable name. If it's greater
  682. * than maxResultSize, the returned displayable name will be truncated.
  683. * @stable ICU 2.0
  684. */
  685. U_STABLE int32_t U_EXPORT2
  686. uloc_getDisplayName(const char* localeID,
  687. const char* inLocaleID,
  688. UChar* result,
  689. int32_t maxResultSize,
  690. UErrorCode* err);
  691. /**
  692. * Gets the specified locale from a list of all available locales.
  693. * The return value is a pointer to an item of
  694. * a locale name array. Both this array and the pointers
  695. * it contains are owned by ICU and should not be deleted or written through
  696. * by the caller. The locale name is terminated by a null pointer.
  697. * @param n the specific locale name index of the available locale list
  698. * @return a specified locale name of all available locales
  699. * @stable ICU 2.0
  700. */
  701. U_STABLE const char* U_EXPORT2
  702. uloc_getAvailable(int32_t n);
  703. /**
  704. * Gets the size of the all available locale list.
  705. *
  706. * @return the size of the locale list
  707. * @stable ICU 2.0
  708. */
  709. U_STABLE int32_t U_EXPORT2 uloc_countAvailable(void);
  710. /**
  711. *
  712. * Gets a list of all available language codes defined in ISO 639. This is a pointer
  713. * to an array of pointers to arrays of char. All of these pointers are owned
  714. * by ICU-- do not delete them, and do not write through them. The array is
  715. * terminated with a null pointer.
  716. * @return a list of all available language codes
  717. * @stable ICU 2.0
  718. */
  719. U_STABLE const char* const* U_EXPORT2
  720. uloc_getISOLanguages(void);
  721. /**
  722. *
  723. * Gets a list of all available 2-letter country codes defined in ISO 639. This is a
  724. * pointer to an array of pointers to arrays of char. All of these pointers are
  725. * owned by ICU-- do not delete them, and do not write through them. The array is
  726. * terminated with a null pointer.
  727. * @return a list of all available country codes
  728. * @stable ICU 2.0
  729. */
  730. U_STABLE const char* const* U_EXPORT2
  731. uloc_getISOCountries(void);
  732. /**
  733. * Truncate the locale ID string to get the parent locale ID.
  734. * Copies the part of the string before the last underscore.
  735. * The parent locale ID will be an empty string if there is no
  736. * underscore, or if there is only one underscore at localeID[0].
  737. *
  738. * @param localeID Input locale ID string.
  739. * @param parent Output string buffer for the parent locale ID.
  740. * @param parentCapacity Size of the output buffer.
  741. * @param err A UErrorCode value.
  742. * @return The length of the parent locale ID.
  743. * @stable ICU 2.0
  744. */
  745. U_STABLE int32_t U_EXPORT2
  746. uloc_getParent(const char* localeID,
  747. char* parent,
  748. int32_t parentCapacity,
  749. UErrorCode* err);
  750. /**
  751. * Gets the full name for the specified locale.
  752. * Note: This has the effect of 'canonicalizing' the string to
  753. * a certain extent. Upper and lower case are set as needed,
  754. * and if the components were in 'POSIX' format they are changed to
  755. * ICU format. It does NOT map aliased names in any way.
  756. * See the top of this header file.
  757. * This API strips off the keyword part, so "de_DE\@collation=phonebook"
  758. * will become "de_DE".
  759. * This API supports preflighting.
  760. *
  761. * @param localeID the locale to get the full name with
  762. * @param name fill in buffer for the name without keywords.
  763. * @param nameCapacity capacity of the fill in buffer.
  764. * @param err error information if retrieving the full name failed
  765. * @return the actual buffer size needed for the full name. If it's greater
  766. * than nameCapacity, the returned full name will be truncated.
  767. * @stable ICU 2.8
  768. */
  769. U_STABLE int32_t U_EXPORT2
  770. uloc_getBaseName(const char* localeID,
  771. char* name,
  772. int32_t nameCapacity,
  773. UErrorCode* err);
  774. /**
  775. * Gets an enumeration of keywords for the specified locale. Enumeration
  776. * must get disposed of by the client using uenum_close function.
  777. *
  778. * @param localeID the locale to get the variant code with
  779. * @param status error information if retrieving the keywords failed
  780. * @return enumeration of keywords or NULL if there are no keywords.
  781. * @stable ICU 2.8
  782. */
  783. U_STABLE UEnumeration* U_EXPORT2
  784. uloc_openKeywords(const char* localeID,
  785. UErrorCode* status);
  786. /**
  787. * Get the value for a keyword. Locale name does not need to be normalized.
  788. *
  789. * @param localeID locale name containing the keyword ("de_DE@currency=EURO;collation=PHONEBOOK")
  790. * @param keywordName name of the keyword for which we want the value. Case insensitive.
  791. * @param buffer receiving buffer
  792. * @param bufferCapacity capacity of receiving buffer
  793. * @param status containing error code - buffer not big enough.
  794. * @return the length of keyword value
  795. * @stable ICU 2.8
  796. */
  797. U_STABLE int32_t U_EXPORT2
  798. uloc_getKeywordValue(const char* localeID,
  799. const char* keywordName,
  800. char* buffer, int32_t bufferCapacity,
  801. UErrorCode* status);
  802. /**
  803. * Set the value of the specified keyword.
  804. * NOTE: Unlike almost every other ICU function which takes a
  805. * buffer, this function will NOT truncate the output text. If a
  806. * BUFFER_OVERFLOW_ERROR is received, it means that the original
  807. * buffer is untouched. This is done to prevent incorrect or possibly
  808. * even malformed locales from being generated and used.
  809. *
  810. * @param keywordName name of the keyword to be set. Case insensitive.
  811. * @param keywordValue value of the keyword to be set. If 0-length or
  812. * NULL, will result in the keyword being removed. No error is given if
  813. * that keyword does not exist.
  814. * @param buffer input buffer containing locale to be modified.
  815. * @param bufferCapacity capacity of receiving buffer
  816. * @param status containing error code - buffer not big enough.
  817. * @return the length needed for the buffer
  818. * @see uloc_getKeywordValue
  819. * @stable ICU 3.2
  820. */
  821. U_STABLE int32_t U_EXPORT2
  822. uloc_setKeywordValue(const char* keywordName,
  823. const char* keywordValue,
  824. char* buffer, int32_t bufferCapacity,
  825. UErrorCode* status);
  826. /**
  827. * enums for the return value for the character and line orientation
  828. * functions.
  829. * @stable ICU 4.0
  830. */
  831. typedef enum {
  832. ULOC_LAYOUT_LTR = 0, /* left-to-right. */
  833. ULOC_LAYOUT_RTL = 1, /* right-to-left. */
  834. ULOC_LAYOUT_TTB = 2, /* top-to-bottom. */
  835. ULOC_LAYOUT_BTT = 3, /* bottom-to-top. */
  836. ULOC_LAYOUT_UNKNOWN
  837. } ULayoutType;
  838. /**
  839. * Get the layout character orientation for the specified locale.
  840. *
  841. * @param localeId locale name
  842. * @param status Error status
  843. * @return an enum indicating the layout orientation for characters.
  844. * @stable ICU 4.0
  845. */
  846. U_STABLE ULayoutType U_EXPORT2
  847. uloc_getCharacterOrientation(const char* localeId,
  848. UErrorCode *status);
  849. /**
  850. * Get the layout line orientation for the specified locale.
  851. *
  852. * @param localeId locale name
  853. * @param status Error status
  854. * @return an enum indicating the layout orientation for lines.
  855. * @stable ICU 4.0
  856. */
  857. U_STABLE ULayoutType U_EXPORT2
  858. uloc_getLineOrientation(const char* localeId,
  859. UErrorCode *status);
  860. /**
  861. * enums for the 'outResult' parameter return value
  862. * @see uloc_acceptLanguageFromHTTP
  863. * @see uloc_acceptLanguage
  864. * @stable ICU 3.2
  865. */
  866. typedef enum {
  867. ULOC_ACCEPT_FAILED = 0, /* No exact match was found. */
  868. ULOC_ACCEPT_VALID = 1, /* An exact match was found. */
  869. ULOC_ACCEPT_FALLBACK = 2 /* A fallback was found, for example,
  870. Accept list contained 'ja_JP'
  871. which matched available locale 'ja'. */
  872. } UAcceptResult;
  873. /**
  874. * Based on a HTTP header from a web browser and a list of available locales,
  875. * determine an acceptable locale for the user.
  876. * @param result - buffer to accept the result locale
  877. * @param resultAvailable the size of the result buffer.
  878. * @param outResult - An out parameter that contains the fallback status
  879. * @param httpAcceptLanguage - "Accept-Language:" header as per HTTP.
  880. * @param availableLocales - list of available locales to match
  881. * @param status Error status, may be BUFFER_OVERFLOW_ERROR
  882. * @return length needed for the locale.
  883. * @stable ICU 3.2
  884. */
  885. U_STABLE int32_t U_EXPORT2
  886. uloc_acceptLanguageFromHTTP(char *result, int32_t resultAvailable,
  887. UAcceptResult *outResult,
  888. const char *httpAcceptLanguage,
  889. UEnumeration* availableLocales,
  890. UErrorCode *status);
  891. /**
  892. * Based on a list of available locales,
  893. * determine an acceptable locale for the user.
  894. * @param result - buffer to accept the result locale
  895. * @param resultAvailable the size of the result buffer.
  896. * @param outResult - An out parameter that contains the fallback status
  897. * @param acceptList - list of acceptable languages
  898. * @param acceptListCount - count of acceptList items
  899. * @param availableLocales - list of available locales to match
  900. * @param status Error status, may be BUFFER_OVERFLOW_ERROR
  901. * @return length needed for the locale.
  902. * @stable ICU 3.2
  903. */
  904. U_STABLE int32_t U_EXPORT2
  905. uloc_acceptLanguage(char *result, int32_t resultAvailable,
  906. UAcceptResult *outResult, const char **acceptList,
  907. int32_t acceptListCount,
  908. UEnumeration* availableLocales,
  909. UErrorCode *status);
  910. /**
  911. * Gets the ICU locale ID for the specified Win32 LCID value.
  912. *
  913. * @param hostID the Win32 LCID to translate
  914. * @param locale the output buffer for the ICU locale ID, which will be NUL-terminated
  915. * if there is room.
  916. * @param localeCapacity the size of the output buffer
  917. * @param status an error is returned if the LCID is unrecognized or the output buffer
  918. * is too small
  919. * @return actual the actual size of the locale ID, not including NUL-termination
  920. * @stable ICU 3.8
  921. */
  922. U_STABLE int32_t U_EXPORT2
  923. uloc_getLocaleForLCID(uint32_t hostID, char *locale, int32_t localeCapacity,
  924. UErrorCode *status);
  925. /**
  926. * Add the likely subtags for a provided locale ID, per the algorithm described
  927. * in the following CLDR technical report:
  928. *
  929. * http://www.unicode.org/reports/tr35/#Likely_Subtags
  930. *
  931. * If localeID is already in the maximal form, or there is no data available
  932. * for maximization, it will be copied to the output buffer. For example,
  933. * "und-Zzzz" cannot be maximized, since there is no reasonable maximization.
  934. *
  935. * Examples:
  936. *
  937. * "en" maximizes to "en_Latn_US"
  938. *
  939. * "de" maximizes to "de_Latn_US"
  940. *
  941. * "sr" maximizes to "sr_Cyrl_RS"
  942. *
  943. * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.)
  944. *
  945. * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.)
  946. *
  947. * @param localeID The locale to maximize
  948. * @param maximizedLocaleID The maximized locale
  949. * @param maximizedLocaleIDCapacity The capacity of the maximizedLocaleID buffer
  950. * @param err Error information if maximizing the locale failed. If the length
  951. * of the localeID and the null-terminator is greater than the maximum allowed size,
  952. * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
  953. * @return The actual buffer size needed for the maximized locale. If it's
  954. * greater than maximizedLocaleIDCapacity, the returned ID will be truncated.
  955. * On error, the return value is -1.
  956. * @stable ICU 4.0
  957. */
  958. U_STABLE int32_t U_EXPORT2
  959. uloc_addLikelySubtags(const char* localeID,
  960. char* maximizedLocaleID,
  961. int32_t maximizedLocaleIDCapacity,
  962. UErrorCode* err);
  963. /**
  964. * Minimize the subtags for a provided locale ID, per the algorithm described
  965. * in the following CLDR technical report:
  966. *
  967. * http://www.unicode.org/reports/tr35/#Likely_Subtags
  968. *
  969. * If localeID is already in the minimal form, or there is no data available
  970. * for minimization, it will be copied to the output buffer. Since the
  971. * minimization algorithm relies on proper maximization, see the comments
  972. * for uloc_addLikelySubtags for reasons why there might not be any data.
  973. *
  974. * Examples:
  975. *
  976. * "en_Latn_US" minimizes to "en"
  977. *
  978. * "de_Latn_US" minimizes to "de"
  979. *
  980. * "sr_Cyrl_RS" minimizes to "sr"
  981. *
  982. * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the
  983. * script, and minimizing to "zh" would imply "zh_Hans_CN".)
  984. *
  985. * @param localeID The locale to minimize
  986. * @param minimizedLocaleID The minimized locale
  987. * @param minimizedLocaleIDCapacity The capacity of the minimizedLocaleID buffer
  988. * @param err Error information if minimizing the locale failed. If the length
  989. * of the localeID and the null-terminator is greater than the maximum allowed size,
  990. * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR.
  991. * @return The actual buffer size needed for the minimized locale. If it's
  992. * greater than minimizedLocaleIDCapacity, the returned ID will be truncated.
  993. * On error, the return value is -1.
  994. * @stable ICU 4.0
  995. */
  996. U_STABLE int32_t U_EXPORT2
  997. uloc_minimizeSubtags(const char* localeID,
  998. char* minimizedLocaleID,
  999. int32_t minimizedLocaleIDCapacity,
  1000. UErrorCode* err);
  1001. /**
  1002. * Returns a locale ID for the specified BCP47 language tag string.
  1003. * If the specified language tag contains any ill-formed subtags,
  1004. * the first such subtag and all following subtags are ignored.
  1005. * <p>
  1006. * This implements the 'Language-Tag' production of BCP47, and so
  1007. * supports grandfathered (regular and irregular) as well as private
  1008. * use language tags. Private use tags are represented as 'x-whatever',
  1009. * and grandfathered tags are converted to their canonical replacements
  1010. * where they exist. Note that a few grandfathered tags have no modern
  1011. * replacement, these will be converted using the fallback described in
  1012. * the first paragraph, so some information might be lost.
  1013. * @param langtag the input BCP47 language tag.
  1014. * @param localeID the output buffer receiving a locale ID for the
  1015. * specified BCP47 language tag.
  1016. * @param localeIDCapacity the size of the locale ID output buffer.
  1017. * @param parsedLength if not NULL, succsessfully parsed length
  1018. * for the input language tag is set.
  1019. * @param err error information if receiving the locald ID
  1020. * failed.
  1021. * @return the length of the locale ID.
  1022. * @draft ICU 4.2
  1023. */
  1024. U_DRAFT int32_t U_EXPORT2
  1025. uloc_forLanguageTag(const char* langtag,
  1026. char* localeID,
  1027. int32_t localeIDCapacity,
  1028. int32_t* parsedLength,
  1029. UErrorCode* err);
  1030. /**
  1031. * Returns a well-formed language tag for this locale ID.
  1032. * <p>
  1033. * <b>Note</b>: When <code>strict</code> is FALSE, any locale
  1034. * fields which do not satisfy the BCP47 syntax requirement will
  1035. * be omitted from the result. When <code>strict</code> is
  1036. * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the
  1037. * <code>err</code> if any locale fields do not satisfy the
  1038. * BCP47 syntax requirement.
  1039. * @param localeID the input lcoale ID
  1040. * @param langtag the output buffer receiving BCP47 language
  1041. * tag for the locale ID.
  1042. * @param langtagCapacity the size of the BCP47 language tag
  1043. * output buffer.
  1044. * @param strict boolean value indicating if the function returns
  1045. * an error for an ill-formed input locale ID.
  1046. * @param err error information if receiving the language
  1047. * tag failed.
  1048. * @return The length of the BCP47 language tag.
  1049. * @draft ICU 4.2
  1050. */
  1051. U_DRAFT int32_t U_EXPORT2
  1052. uloc_toLanguageTag(const char* localeID,
  1053. char* langtag,
  1054. int32_t langtagCapacity,
  1055. UBool strict,
  1056. UErrorCode* err);
  1057. #endif /*_ULOC*/