]> git.saurik.com Git - apple/cf.git/blob - CFLocale.h
21edcc2ab09034ec45bc7cf2fa256a3b5277d9f8
[apple/cf.git] / CFLocale.h
1 /*
2 * Copyright (c) 2014 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 /* CFLocale.h
25 Copyright (c) 2002-2014, Apple Inc. All rights reserved.
26 */
27
28 #if !defined(__COREFOUNDATION_CFLOCALE__)
29 #define __COREFOUNDATION_CFLOCALE__ 1
30
31 #include <CoreFoundation/CFBase.h>
32 #include <CoreFoundation/CFArray.h>
33 #include <CoreFoundation/CFDictionary.h>
34
35 CF_IMPLICIT_BRIDGING_ENABLED
36 CF_EXTERN_C_BEGIN
37
38 typedef const struct CF_BRIDGED_TYPE(NSLocale) __CFLocale *CFLocaleRef;
39
40 CF_EXPORT
41 CFTypeID CFLocaleGetTypeID(void);
42
43 CF_EXPORT
44 CFLocaleRef CFLocaleGetSystem(void);
45 // Returns the "root", canonical locale. Contains fixed "backstop" settings.
46
47 CF_EXPORT
48 CFLocaleRef CFLocaleCopyCurrent(void);
49 // Returns the logical "user" locale for the current user.
50 // [This is Copy in the sense that you get a retain you have to release,
51 // but we may return the same cached object over and over.] Settings
52 // you get from this locale do not change under you as CFPreferences
53 // are changed (for safety and correctness). Generally you would not
54 // grab this and hold onto it forever, but use it to do the operations
55 // you need to do at the moment, then throw it away. (The non-changing
56 // ensures that all the results of your operations are consistent.)
57
58 CF_EXPORT
59 CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void);
60 // Returns an array of CFStrings that represents all locales for
61 // which locale data is available.
62
63 CF_EXPORT
64 CFArrayRef CFLocaleCopyISOLanguageCodes(void);
65 // Returns an array of CFStrings that represents all known legal ISO
66 // language codes. Note: many of these will not have any supporting
67 // locale data in Mac OS X.
68
69 CF_EXPORT
70 CFArrayRef CFLocaleCopyISOCountryCodes(void);
71 // Returns an array of CFStrings that represents all known legal ISO
72 // country codes. Note: many of these will not have any supporting
73 // locale data in Mac OS X.
74
75 CF_EXPORT
76 CFArrayRef CFLocaleCopyISOCurrencyCodes(void);
77 // Returns an array of CFStrings that represents all known legal ISO
78 // currency codes. Note: some of these currencies may be obsolete, or
79 // represent other financial instruments.
80
81 CF_EXPORT
82 CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) CF_AVAILABLE(10_5, 2_0);
83 // Returns an array of CFStrings that represents ISO currency codes for
84 // currencies in common use.
85
86 CF_EXPORT
87 CFArrayRef CFLocaleCopyPreferredLanguages(void) CF_AVAILABLE(10_5, 2_0);
88 // Returns the array of canonicalized CFString locale IDs that the user prefers.
89
90 CF_EXPORT
91 CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier);
92 // Map an arbitrary language identification string (something close at
93 // least) to a canonical language identifier.
94
95 CF_EXPORT
96 CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier);
97 // Map an arbitrary locale identification string (something close at
98 // least) to the canonical identifier.
99
100 CF_EXPORT
101 CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode);
102 // Map a Mac OS LangCode and RegionCode to the canonical locale identifier.
103
104 CF_EXPORT
105 CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) CF_AVAILABLE(10_6, 4_0);
106 // Map a Windows LCID to the canonical locale identifier.
107
108 CF_EXPORT
109 uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) CF_AVAILABLE(10_6, 4_0);
110 // Map a locale identifier to a Windows LCID.
111
112 typedef CF_ENUM(CFIndex, CFLocaleLanguageDirection) {
113 kCFLocaleLanguageDirectionUnknown = 0,
114 kCFLocaleLanguageDirectionLeftToRight = 1,
115 kCFLocaleLanguageDirectionRightToLeft = 2,
116 kCFLocaleLanguageDirectionTopToBottom = 3,
117 kCFLocaleLanguageDirectionBottomToTop = 4
118 };
119
120 CF_EXPORT
121 CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0);
122
123 CF_EXPORT
124 CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0);
125
126 CF_EXPORT
127 CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID);
128 // Parses a locale ID consisting of language, script, country, variant,
129 // and keyword/value pairs into a dictionary. The keys are the constant
130 // CFStrings corresponding to the locale ID components, and the values
131 // will correspond to constants where available.
132 // Example: "en_US@calendar=japanese" yields a dictionary with three
133 // entries: kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, and
134 // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar.
135
136 CF_EXPORT
137 CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary);
138 // Reverses the actions of CFLocaleCreateDictionaryFromLocaleIdentifier,
139 // creating a single string from the data in the dictionary. The
140 // dictionary {kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US,
141 // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar} becomes
142 // "en_US@calendar=japanese".
143
144 CF_EXPORT
145 CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier);
146 // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier.
147
148 CF_EXPORT
149 CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale);
150 // Having gotten a CFLocale from somebody, code should make a copy
151 // if it is going to use it for several operations
152 // or hold onto it. In the future, there may be mutable locales.
153
154 CF_EXPORT
155 CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale);
156 // Returns the locale's identifier. This may not be the same string
157 // that the locale was created with (CFLocale may canonicalize it).
158
159 CF_EXPORT
160 CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key);
161 // Returns the value for the given key. This is how settings and state
162 // are accessed via a CFLocale. Values might be of any CF type.
163
164 CF_EXPORT
165 CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value);
166 // Returns the display name for the given value. The key tells what
167 // the value is, and is one of the usual locale property keys, though
168 // not all locale property keys have values with display name values.
169
170
171 CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification CF_AVAILABLE(10_5, 2_0);
172
173
174 // Locale Keys
175 CF_EXPORT const CFStringRef kCFLocaleIdentifier;
176 CF_EXPORT const CFStringRef kCFLocaleLanguageCode;
177 CF_EXPORT const CFStringRef kCFLocaleCountryCode;
178 CF_EXPORT const CFStringRef kCFLocaleScriptCode;
179 CF_EXPORT const CFStringRef kCFLocaleVariantCode;
180
181 CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet;
182 CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier;
183 CF_EXPORT const CFStringRef kCFLocaleCalendar;
184 CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier;
185 CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem;
186 CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; // "Metric" or "U.S."
187 CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator;
188 CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator;
189 CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol;
190 CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; // ISO 3-letter currency code
191 CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier CF_AVAILABLE(10_6, 4_0);
192 CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0);
193 CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0);
194 CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0);
195 CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0);
196
197 // Values for kCFLocaleCalendarIdentifier
198 CF_EXPORT const CFStringRef kCFGregorianCalendar;
199 CF_EXPORT const CFStringRef kCFBuddhistCalendar;
200 CF_EXPORT const CFStringRef kCFChineseCalendar;
201 CF_EXPORT const CFStringRef kCFHebrewCalendar;
202 CF_EXPORT const CFStringRef kCFIslamicCalendar;
203 CF_EXPORT const CFStringRef kCFIslamicCivilCalendar;
204 CF_EXPORT const CFStringRef kCFJapaneseCalendar;
205 CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar CF_AVAILABLE(10_6, 4_0);
206 CF_EXPORT const CFStringRef kCFPersianCalendar CF_AVAILABLE(10_6, 4_0);
207 CF_EXPORT const CFStringRef kCFIndianCalendar CF_AVAILABLE(10_6, 4_0);
208 CF_EXPORT const CFStringRef kCFISO8601Calendar CF_AVAILABLE(10_6, 4_0);
209 CF_EXPORT const CFStringRef kCFIslamicTabularCalendar CF_AVAILABLE(10_10, 8_0);
210 CF_EXPORT const CFStringRef kCFIslamicUmmAlQuraCalendar CF_AVAILABLE(10_10, 8_0);
211
212 CF_EXTERN_C_END
213 CF_IMPLICIT_BRIDGING_DISABLED
214
215 #endif /* ! __COREFOUNDATION_CFLOCALE__ */
216