• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 *   Copyright (C) 2004-2016, International Business Machines
6 *   Corporation and others.  All Rights Reserved.
7 **********************************************************************
8 */
9 
10 #ifndef ULOCIMP_H
11 #define ULOCIMP_H
12 
13 #include "unicode/uloc.h"
14 
15 /**
16  * Create an iterator over the specified keywords list
17  * @param keywordList double-null terminated list. Will be copied.
18  * @param keywordListSize size in bytes of keywordList
19  * @param status err code
20  * @return enumeration (owned by caller) of the keyword list.
21  * @internal ICU 3.0
22  */
23 U_CAPI UEnumeration* U_EXPORT2
24 uloc_openKeywordList(const char *keywordList, int32_t keywordListSize, UErrorCode* status);
25 
26 /**
27  * Look up a resource bundle table item with fallback on the table level.
28  * This is accessible so it can be called by C++ code.
29  */
30 U_CAPI const UChar * U_EXPORT2
31 uloc_getTableStringWithFallback(
32     const char *path,
33     const char *locale,
34     const char *tableKey,
35     const char *subTableKey,
36     const char *itemKey,
37     int32_t *pLength,
38     UErrorCode *pErrorCode);
39 
40 /*returns TRUE if a is an ID separator FALSE otherwise*/
41 #define _isIDSeparator(a) (a == '_' || a == '-')
42 
43 U_CFUNC const char*
44 uloc_getCurrentCountryID(const char* oldID);
45 
46 U_CFUNC const char*
47 uloc_getCurrentLanguageID(const char* oldID);
48 
49 U_CFUNC int32_t
50 ulocimp_getLanguage(const char *localeID,
51                     char *language, int32_t languageCapacity,
52                     const char **pEnd);
53 
54 U_CFUNC int32_t
55 ulocimp_getScript(const char *localeID,
56                    char *script, int32_t scriptCapacity,
57                    const char **pEnd);
58 
59 U_CFUNC int32_t
60 ulocimp_getCountry(const char *localeID,
61                    char *country, int32_t countryCapacity,
62                    const char **pEnd);
63 
64 /**
65  * Returns a locale ID for the specified BCP47 language tag string.
66  * If the specified language tag contains any ill-formed subtags,
67  * the first such subtag and all following subtags are ignored.
68  * <p>
69  * This implements the 'Language-Tag' production of BCP47, and so
70  * supports grandfathered (regular and irregular) as well as private
71  * use language tags.  Private use tags are represented as 'x-whatever',
72  * and grandfathered tags are converted to their canonical replacements
73  * where they exist.  Note that a few grandfathered tags have no modern
74  * replacement, these will be converted using the fallback described in
75  * the first paragraph, so some information might be lost.
76  * @param langtag   the input BCP47 language tag.
77  * @param tagLen    the length of langtag, or -1 to call uprv_strlen().
78  * @param localeID  the output buffer receiving a locale ID for the
79  *                  specified BCP47 language tag.
80  * @param localeIDCapacity  the size of the locale ID output buffer.
81  * @param parsedLength  if not NULL, successfully parsed length
82  *                      for the input language tag is set.
83  * @param err       error information if receiving the locald ID
84  *                  failed.
85  * @return          the length of the locale ID.
86  * @internal ICU 63
87  */
88 U_CAPI int32_t U_EXPORT2
89 ulocimp_forLanguageTag(const char* langtag,
90                        int32_t tagLen,
91                        char* localeID,
92                        int32_t localeIDCapacity,
93                        int32_t* parsedLength,
94                        UErrorCode* err);
95 
96 /**
97  * Get the region to use for supplemental data lookup. Uses
98  * (1) any region specified by locale tag "rg"; if none then
99  * (2) any unicode_region_tag in the locale ID; if none then
100  * (3) if inferRegion is TRUE, the region suggested by
101  * getLikelySubtags on the localeID.
102  * If no region is found, returns length 0.
103  *
104  * @param localeID
105  *     The complete locale ID (with keywords) from which
106  *     to get the region to use for supplemental data.
107  * @param inferRegion
108  *     If TRUE, will try to infer region from localeID if
109  *     no other region is found.
110  * @param region
111  *     Buffer in which to put the region ID found; should
112  *     have a capacity at least ULOC_COUNTRY_CAPACITY.
113  * @param regionCapacity
114  *     The actual capacity of the region buffer.
115  * @param status
116  *     Pointer to in/out UErrorCode value for latest status.
117  * @return
118  *     The length of any region code found, or 0 if none.
119  * @internal ICU 57
120  */
121 U_CAPI int32_t U_EXPORT2
122 ulocimp_getRegionForSupplementalData(const char *localeID, UBool inferRegion,
123                                      char *region, int32_t regionCapacity, UErrorCode* status);
124 
125 U_CAPI const char * U_EXPORT2
126 locale_getKeywordsStart(const char *localeID);
127 
128 
129 U_CFUNC UBool
130 ultag_isUnicodeLocaleKey(const char* s, int32_t len);
131 
132 U_CFUNC UBool
133 ultag_isUnicodeLocaleType(const char* s, int32_t len);
134 
135 U_CFUNC const char*
136 ulocimp_toBcpKey(const char* key);
137 
138 U_CFUNC const char*
139 ulocimp_toLegacyKey(const char* key);
140 
141 U_CFUNC const char*
142 ulocimp_toBcpType(const char* key, const char* type, UBool* isKnownKey, UBool* isSpecialType);
143 
144 U_CFUNC const char*
145 ulocimp_toLegacyType(const char* key, const char* type, UBool* isKnownKey, UBool* isSpecialType);
146 
147 #endif
148