]> git.saurik.com Git - apple/cf.git/blob - CFLocale.h
CF-550.19.tar.gz
[apple/cf.git] / CFLocale.h
1 /*
2 * Copyright (c) 2010 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-2009, 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 #if MAC_OS_X_VERSION_10_3 <= MAC_OS_X_VERSION_MAX_ALLOWED
36
37 CF_EXTERN_C_BEGIN
38
39 typedef const struct __CFLocale *CFLocaleRef;
40
41 CF_EXPORT
42 CFTypeID CFLocaleGetTypeID(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
43
44 CF_EXPORT
45 CFLocaleRef CFLocaleGetSystem(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
46 // Returns the "root", canonical locale. Contains fixed "backstop" settings.
47
48 CF_EXPORT
49 CFLocaleRef CFLocaleCopyCurrent(void) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
50 // Returns the logical "user" locale for the current user.
51 // [This is Copy in the sense that you get a retain you have to release,
52 // but we may return the same cached object over and over.] Settings
53 // you get from this locale do not change under you as CFPreferences
54 // are changed (for safety and correctness). Generally you would not
55 // grab this and hold onto it forever, but use it to do the operations
56 // you need to do at the moment, then throw it away. (The non-changing
57 // ensures that all the results of your operations are consistent.)
58
59 CF_EXPORT
60 CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
61 // Returns an array of CFStrings that represents all locales for
62 // which locale data is available.
63
64 CF_EXPORT
65 CFArrayRef CFLocaleCopyISOLanguageCodes(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
66 // Returns an array of CFStrings that represents all known legal ISO
67 // language codes. Note: many of these will not have any supporting
68 // locale data in Mac OS X.
69
70 CF_EXPORT
71 CFArrayRef CFLocaleCopyISOCountryCodes(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
72 // Returns an array of CFStrings that represents all known legal ISO
73 // country codes. Note: many of these will not have any supporting
74 // locale data in Mac OS X.
75
76 CF_EXPORT
77 CFArrayRef CFLocaleCopyISOCurrencyCodes(void) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
78 // Returns an array of CFStrings that represents all known legal ISO
79 // currency codes. Note: some of these currencies may be obsolete, or
80 // represent other financial instruments.
81
82 CF_EXPORT
83 CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
84 // Returns an array of CFStrings that represents ISO currency codes for
85 // currencies in common use.
86
87 CF_EXPORT
88 CFArrayRef CFLocaleCopyPreferredLanguages(void) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
89 // Returns the array of canonicalized CFString locale IDs that the user prefers.
90
91 CF_EXPORT
92 CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
93 // Map an arbitrary language identification string (something close at
94 // least) to a canonical language identifier.
95
96 CF_EXPORT
97 CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
98 // Map an arbitrary locale identification string (something close at
99 // least) to the canonical identifier.
100
101 CF_EXPORT
102 CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
103 // Map a Mac OS LangCode and RegionCode to the canonical locale identifier.
104
105 CF_EXPORT
106 CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
107 // Map a Windows LCID to the canonical locale identifier.
108
109 CF_EXPORT
110 uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
111 // Map a locale identifier to a Windows LCID.
112
113 enum {
114 kCFLocaleLanguageDirectionUnknown = 0,
115 kCFLocaleLanguageDirectionLeftToRight = 1,
116 kCFLocaleLanguageDirectionRightToLeft = 2,
117 kCFLocaleLanguageDirectionTopToBottom = 3,
118 kCFLocaleLanguageDirectionBottomToTop = 4
119 };
120 typedef CFIndex CFLocaleLanguageDirection;
121
122 CF_EXPORT
123 CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
124
125 CF_EXPORT
126 CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
127
128 CF_EXPORT
129 CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
130 // Parses a locale ID consisting of language, script, country, variant,
131 // and keyword/value pairs into a dictionary. The keys are the constant
132 // CFStrings corresponding to the locale ID components, and the values
133 // will correspond to constants where available.
134 // Example: "en_US@calendar=japanese" yields a dictionary with three
135 // entries: kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US, and
136 // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar.
137
138 CF_EXPORT
139 CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
140 // Reverses the actions of CFLocaleCreateDictionaryFromLocaleIdentifier,
141 // creating a single string from the data in the dictionary. The
142 // dictionary {kCFLocaleLanguageCode=en, kCFLocaleCountryCode=US,
143 // kCFLocaleCalendarIdentifier=kCFJapaneseCalendar} becomes
144 // "en_US@calendar=japanese".
145
146 CF_EXPORT
147 CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
148 // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier.
149
150 CF_EXPORT
151 CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
152 // Having gotten a CFLocale from somebody, code should make a copy
153 // if it is going to use it for several operations
154 // or hold onto it. In the future, there may be mutable locales.
155
156 CF_EXPORT
157 CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
158 // Returns the locale's identifier. This may not be the same string
159 // that the locale was created with (CFLocale may canonicalize it).
160
161 CF_EXPORT
162 CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
163 // Returns the value for the given key. This is how settings and state
164 // are accessed via a CFLocale. Values might be of any CF type.
165
166 CF_EXPORT
167 CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value) AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
168 // Returns the display name for the given value. The key tells what
169 // the value is, and is one of the usual locale property keys, though
170 // not all locale property keys have values with display name values.
171
172
173 CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER;
174
175
176 // Locale Keys
177 CF_EXPORT const CFStringRef kCFLocaleIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
178 CF_EXPORT const CFStringRef kCFLocaleLanguageCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
179 CF_EXPORT const CFStringRef kCFLocaleCountryCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
180 CF_EXPORT const CFStringRef kCFLocaleScriptCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
181 CF_EXPORT const CFStringRef kCFLocaleVariantCode AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
182
183 CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
184 CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
185 CF_EXPORT const CFStringRef kCFLocaleCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
186 CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
187 CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
188 CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // "Metric" or "U.S."
189 CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
190 CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
191 CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
192 CF_EXPORT const CFStringRef kCFLocaleCurrencyCode AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; // ISO 3-letter currency code
193 CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
194 CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
195 CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
196 CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
197 CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
198
199 // Values for kCFLocaleCalendarIdentifier
200 CF_EXPORT const CFStringRef kCFGregorianCalendar AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
201 CF_EXPORT const CFStringRef kCFBuddhistCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
202 CF_EXPORT const CFStringRef kCFChineseCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
203 CF_EXPORT const CFStringRef kCFHebrewCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
204 CF_EXPORT const CFStringRef kCFIslamicCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
205 CF_EXPORT const CFStringRef kCFIslamicCivilCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
206 CF_EXPORT const CFStringRef kCFJapaneseCalendar AVAILABLE_MAC_OS_X_VERSION_10_4_AND_LATER;
207 CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
208 CF_EXPORT const CFStringRef kCFPersianCalendar AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
209 CF_EXPORT const CFStringRef kCFIndianCalendar AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
210 CF_EXPORT const CFStringRef kCFISO8601Calendar AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER;
211
212 CF_EXTERN_C_END
213
214 #endif
215
216 #endif /* ! __COREFOUNDATION_CFLOCALE__ */
217