]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/ulocimp.h
   1 // © 2016 and later: Unicode, Inc. and others. 
   2 // License & terms of use: http://www.unicode.org/copyright.html 
   4 ********************************************************************** 
   5 *   Copyright (C) 2004-2016, International Business Machines 
   6 *   Corporation and others.  All Rights Reserved. 
   7 ********************************************************************** 
  13 #include "unicode/bytestream.h" 
  14 #include "unicode/uloc.h" 
  17  * Create an iterator over the specified keywords list 
  18  * @param keywordList double-null terminated list. Will be copied. 
  19  * @param keywordListSize size in bytes of keywordList 
  20  * @param status err code 
  21  * @return enumeration (owned by caller) of the keyword list. 
  24 U_CAPI UEnumeration
* U_EXPORT2
 
  25 uloc_openKeywordList(const char *keywordList
, int32_t keywordListSize
, UErrorCode
* status
); 
  28  * Look up a resource bundle table item with fallback on the table level. 
  29  * This is accessible so it can be called by C++ code. 
  31 U_CAPI 
const UChar 
* U_EXPORT2
 
  32 uloc_getTableStringWithFallback( 
  36     const char *subTableKey
, 
  39     UErrorCode 
*pErrorCode
); 
  41 /*returns TRUE if a is an ID separator FALSE otherwise*/ 
  42 #define _isIDSeparator(a) (a == '_' || a == '-') 
  45 uloc_getCurrentCountryID(const char* oldID
); 
  48 uloc_getCurrentLanguageID(const char* oldID
); 
  51 ulocimp_getLanguage(const char *localeID
, 
  52                     char *language
, int32_t languageCapacity
, 
  56 ulocimp_getScript(const char *localeID
, 
  57                    char *script
, int32_t scriptCapacity
, 
  61 ulocimp_getCountry(const char *localeID
, 
  62                    char *country
, int32_t countryCapacity
, 
  66  * Writes a well-formed language tag for this locale ID. 
  68  * **Note**: When `strict` is FALSE, any locale fields which do not satisfy the 
  69  * BCP47 syntax requirement will be omitted from the result.  When `strict` is 
  70  * TRUE, this function sets U_ILLEGAL_ARGUMENT_ERROR to the `err` if any locale 
  71  * fields do not satisfy the BCP47 syntax requirement. 
  73  * @param localeID  the input locale ID 
  74  * @param sink      the output sink receiving the BCP47 language 
  75  *                  tag for this Locale. 
  76  * @param strict    boolean value indicating if the function returns 
  77  *                  an error for an ill-formed input locale ID. 
  78  * @param err       error information if receiving the language 
  80  * @return          The length of the BCP47 language tag. 
  84 U_STABLE 
void U_EXPORT2
 
  85 ulocimp_toLanguageTag(const char* localeID
, 
  91  * Returns a locale ID for the specified BCP47 language tag string. 
  92  * If the specified language tag contains any ill-formed subtags, 
  93  * the first such subtag and all following subtags are ignored. 
  95  * This implements the 'Language-Tag' production of BCP47, and so 
  96  * supports grandfathered (regular and irregular) as well as private 
  97  * use language tags.  Private use tags are represented as 'x-whatever', 
  98  * and grandfathered tags are converted to their canonical replacements 
  99  * where they exist.  Note that a few grandfathered tags have no modern 
 100  * replacement, these will be converted using the fallback described in 
 101  * the first paragraph, so some information might be lost. 
 102  * @param langtag   the input BCP47 language tag. 
 103  * @param tagLen    the length of langtag, or -1 to call uprv_strlen(). 
 104  * @param sink      the output sink receiving a locale ID for the 
 105  *                  specified BCP47 language tag. 
 106  * @param parsedLength  if not NULL, successfully parsed length 
 107  *                      for the input language tag is set. 
 108  * @param err       error information if receiving the locald ID 
 112 U_CAPI 
void U_EXPORT2
 
 113 ulocimp_forLanguageTag(const char* langtag
, 
 116                        int32_t* parsedLength
, 
 120  * Get the region to use for supplemental data lookup. Uses 
 121  * (1) any region specified by locale tag "rg"; if none then 
 122  * (2) any unicode_region_tag in the locale ID; if none then 
 123  * (3) if inferRegion is TRUE, the region suggested by 
 124  * getLikelySubtags on the localeID. 
 125  * If no region is found, returns length 0. 
 128  *     The complete locale ID (with keywords) from which 
 129  *     to get the region to use for supplemental data. 
 131  *     If TRUE, will try to infer region from localeID if 
 132  *     no other region is found. 
 134  *     Buffer in which to put the region ID found; should 
 135  *     have a capacity at least ULOC_COUNTRY_CAPACITY.  
 136  * @param regionCapacity 
 137  *     The actual capacity of the region buffer. 
 139  *     Pointer to in/out UErrorCode value for latest status. 
 141  *     The length of any region code found, or 0 if none. 
 144 U_CAPI 
int32_t U_EXPORT2
 
 145 ulocimp_getRegionForSupplementalData(const char *localeID
, UBool inferRegion
, 
 146                                      char *region
, int32_t regionCapacity
, UErrorCode
* status
); 
 149  * Add the likely subtags for a provided locale ID, per the algorithm described 
 150  * in the following CLDR technical report: 
 152  *   http://www.unicode.org/reports/tr35/#Likely_Subtags 
 154  * If localeID is already in the maximal form, or there is no data available 
 155  * for maximization, it will be copied to the output buffer.  For example, 
 156  * "und-Zzzz" cannot be maximized, since there is no reasonable maximization. 
 160  * "en" maximizes to "en_Latn_US" 
 162  * "de" maximizes to "de_Latn_US" 
 164  * "sr" maximizes to "sr_Cyrl_RS" 
 166  * "sh" maximizes to "sr_Latn_RS" (Note this will not reverse.) 
 168  * "zh_Hani" maximizes to "zh_Hans_CN" (Note this will not reverse.) 
 170  * @param localeID The locale to maximize 
 171  * @param sink The output sink receiving the maximized locale 
 172  * @param err Error information if maximizing the locale failed.  If the length 
 173  * of the localeID and the null-terminator is greater than the maximum allowed size, 
 174  * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR. 
 177 U_STABLE 
void U_EXPORT2
 
 178 ulocimp_addLikelySubtags(const char* localeID
, 
 183  * Minimize the subtags for a provided locale ID, per the algorithm described 
 184  * in the following CLDR technical report: 
 186  *   http://www.unicode.org/reports/tr35/#Likely_Subtags 
 188  * If localeID is already in the minimal form, or there is no data available 
 189  * for minimization, it will be copied to the output buffer.  Since the 
 190  * minimization algorithm relies on proper maximization, see the comments 
 191  * for ulocimp_addLikelySubtags for reasons why there might not be any data. 
 195  * "en_Latn_US" minimizes to "en" 
 197  * "de_Latn_US" minimizes to "de" 
 199  * "sr_Cyrl_RS" minimizes to "sr" 
 201  * "zh_Hant_TW" minimizes to "zh_TW" (The region is preferred to the 
 202  * script, and minimizing to "zh" would imply "zh_Hans_CN".) 
 204  * @param localeID The locale to minimize 
 205  * @param sink The output sink receiving the maximized locale 
 206  * @param err Error information if minimizing the locale failed.  If the length 
 207  * of the localeID and the null-terminator is greater than the maximum allowed size, 
 208  * or the localeId is not well-formed, the error code is U_ILLEGAL_ARGUMENT_ERROR. 
 211 U_STABLE 
void U_EXPORT2
 
 212 ulocimp_minimizeSubtags(const char* localeID
, 
 216 U_CAPI 
const char * U_EXPORT2
 
 217 locale_getKeywordsStart(const char *localeID
); 
 220 ultag_isExtensionSubtags(const char* s
, int32_t len
); 
 223 ultag_isLanguageSubtag(const char* s
, int32_t len
); 
 226 ultag_isPrivateuseValueSubtags(const char* s
, int32_t len
); 
 229 ultag_isRegionSubtag(const char* s
, int32_t len
); 
 232 ultag_isScriptSubtag(const char* s
, int32_t len
); 
 235 ultag_isTransformedExtensionSubtags(const char* s
, int32_t len
); 
 238 ultag_isUnicodeExtensionSubtags(const char* s
, int32_t len
); 
 241 ultag_isUnicodeLocaleAttribute(const char* s
, int32_t len
); 
 244 ultag_isUnicodeLocaleAttributes(const char* s
, int32_t len
); 
 247 ultag_isUnicodeLocaleKey(const char* s
, int32_t len
); 
 250 ultag_isUnicodeLocaleType(const char* s
, int32_t len
); 
 253 ultag_isVariantSubtags(const char* s
, int32_t len
); 
 256 ulocimp_toBcpKey(const char* key
); 
 259 ulocimp_toLegacyKey(const char* key
); 
 262 ulocimp_toBcpType(const char* key
, const char* type
, UBool
* isKnownKey
, UBool
* isSpecialType
); 
 265 ulocimp_toLegacyType(const char* key
, const char* type
, UBool
* isKnownKey
, UBool
* isSpecialType
);