]> git.saurik.com Git - apple/cf.git/blame - CFLocale.h
CF-1151.16.tar.gz
[apple/cf.git] / CFLocale.h
CommitLineData
bd5b749c 1/*
d8b101a4 2 * Copyright (c) 2014 Apple Inc. All rights reserved.
bd5b749c
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
d7384798 5 *
bd5b749c
A
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.
d7384798 12 *
bd5b749c
A
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.
d7384798 20 *
bd5b749c
A
21 * @APPLE_LICENSE_HEADER_END@
22 */
f64f9b69 23
bd5b749c 24/* CFLocale.h
d7384798 25 Copyright (c) 2002-2014, Apple Inc. All rights reserved.
bd5b749c
A
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
856091c5 35CF_IMPLICIT_BRIDGING_ENABLED
bd5b749c
A
36CF_EXTERN_C_BEGIN
37
d7384798 38typedef const struct CF_BRIDGED_TYPE(NSLocale) __CFLocale *CFLocaleRef;
bd5b749c
A
39
40CF_EXPORT
8ca704e1 41CFTypeID CFLocaleGetTypeID(void);
bd5b749c
A
42
43CF_EXPORT
8ca704e1 44CFLocaleRef CFLocaleGetSystem(void);
bd5b749c
A
45 // Returns the "root", canonical locale. Contains fixed "backstop" settings.
46
47CF_EXPORT
8ca704e1 48CFLocaleRef CFLocaleCopyCurrent(void);
bd5b749c
A
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
58CF_EXPORT
8ca704e1 59CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void);
bd5b749c
A
60 // Returns an array of CFStrings that represents all locales for
61 // which locale data is available.
62
63CF_EXPORT
8ca704e1 64CFArrayRef CFLocaleCopyISOLanguageCodes(void);
bd5b749c
A
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
69CF_EXPORT
8ca704e1 70CFArrayRef CFLocaleCopyISOCountryCodes(void);
bd5b749c
A
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
75CF_EXPORT
8ca704e1 76CFArrayRef CFLocaleCopyISOCurrencyCodes(void);
bd5b749c
A
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
81CF_EXPORT
8ca704e1 82CFArrayRef CFLocaleCopyCommonISOCurrencyCodes(void) CF_AVAILABLE(10_5, 2_0);
bd5b749c
A
83 // Returns an array of CFStrings that represents ISO currency codes for
84 // currencies in common use.
85
86CF_EXPORT
8ca704e1 87CFArrayRef CFLocaleCopyPreferredLanguages(void) CF_AVAILABLE(10_5, 2_0);
bd5b749c
A
88 // Returns the array of canonicalized CFString locale IDs that the user prefers.
89
90CF_EXPORT
8ca704e1 91CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier);
bd5b749c
A
92 // Map an arbitrary language identification string (something close at
93 // least) to a canonical language identifier.
94
95CF_EXPORT
8ca704e1 96CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier);
bd5b749c
A
97 // Map an arbitrary locale identification string (something close at
98 // least) to the canonical identifier.
99
100CF_EXPORT
8ca704e1 101CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode);
bd5b749c
A
102 // Map a Mac OS LangCode and RegionCode to the canonical locale identifier.
103
cf7d2af9 104CF_EXPORT
8ca704e1 105CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
106 // Map a Windows LCID to the canonical locale identifier.
107
108CF_EXPORT
8ca704e1 109uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
110 // Map a locale identifier to a Windows LCID.
111
856091c5 112typedef CF_ENUM(CFIndex, CFLocaleLanguageDirection) {
cf7d2af9
A
113 kCFLocaleLanguageDirectionUnknown = 0,
114 kCFLocaleLanguageDirectionLeftToRight = 1,
115 kCFLocaleLanguageDirectionRightToLeft = 2,
116 kCFLocaleLanguageDirectionTopToBottom = 3,
117 kCFLocaleLanguageDirectionBottomToTop = 4
118};
cf7d2af9
A
119
120CF_EXPORT
8ca704e1 121CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0);
cf7d2af9
A
122
123CF_EXPORT
8ca704e1 124CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0);
cf7d2af9 125
bd5b749c 126CF_EXPORT
8ca704e1 127CFDictionaryRef CFLocaleCreateComponentsFromLocaleIdentifier(CFAllocatorRef allocator, CFStringRef localeID);
bd5b749c
A
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
136CF_EXPORT
8ca704e1 137CFStringRef CFLocaleCreateLocaleIdentifierFromComponents(CFAllocatorRef allocator, CFDictionaryRef dictionary);
bd5b749c
A
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
144CF_EXPORT
8ca704e1 145CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier);
bd5b749c
A
146 // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier.
147
148CF_EXPORT
8ca704e1 149CFLocaleRef CFLocaleCreateCopy(CFAllocatorRef allocator, CFLocaleRef locale);
bd5b749c
A
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
154CF_EXPORT
8ca704e1 155CFStringRef CFLocaleGetIdentifier(CFLocaleRef locale);
bd5b749c
A
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
159CF_EXPORT
8ca704e1 160CFTypeRef CFLocaleGetValue(CFLocaleRef locale, CFStringRef key);
bd5b749c
A
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
164CF_EXPORT
8ca704e1 165CFStringRef CFLocaleCopyDisplayNameForPropertyValue(CFLocaleRef displayLocale, CFStringRef key, CFStringRef value);
bd5b749c
A
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
8ca704e1 171CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification CF_AVAILABLE(10_5, 2_0);
bd5b749c
A
172
173
174// Locale Keys
8ca704e1
A
175CF_EXPORT const CFStringRef kCFLocaleIdentifier;
176CF_EXPORT const CFStringRef kCFLocaleLanguageCode;
177CF_EXPORT const CFStringRef kCFLocaleCountryCode;
178CF_EXPORT const CFStringRef kCFLocaleScriptCode;
179CF_EXPORT const CFStringRef kCFLocaleVariantCode;
180
181CF_EXPORT const CFStringRef kCFLocaleExemplarCharacterSet;
182CF_EXPORT const CFStringRef kCFLocaleCalendarIdentifier;
183CF_EXPORT const CFStringRef kCFLocaleCalendar;
184CF_EXPORT const CFStringRef kCFLocaleCollationIdentifier;
185CF_EXPORT const CFStringRef kCFLocaleUsesMetricSystem;
186CF_EXPORT const CFStringRef kCFLocaleMeasurementSystem; // "Metric" or "U.S."
187CF_EXPORT const CFStringRef kCFLocaleDecimalSeparator;
188CF_EXPORT const CFStringRef kCFLocaleGroupingSeparator;
189CF_EXPORT const CFStringRef kCFLocaleCurrencySymbol;
190CF_EXPORT const CFStringRef kCFLocaleCurrencyCode; // ISO 3-letter currency code
191CF_EXPORT const CFStringRef kCFLocaleCollatorIdentifier CF_AVAILABLE(10_6, 4_0);
192CF_EXPORT const CFStringRef kCFLocaleQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0);
193CF_EXPORT const CFStringRef kCFLocaleQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0);
194CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationBeginDelimiterKey CF_AVAILABLE(10_6, 4_0);
195CF_EXPORT const CFStringRef kCFLocaleAlternateQuotationEndDelimiterKey CF_AVAILABLE(10_6, 4_0);
bd5b749c
A
196
197// Values for kCFLocaleCalendarIdentifier
8ca704e1
A
198CF_EXPORT const CFStringRef kCFGregorianCalendar;
199CF_EXPORT const CFStringRef kCFBuddhistCalendar;
200CF_EXPORT const CFStringRef kCFChineseCalendar;
201CF_EXPORT const CFStringRef kCFHebrewCalendar;
202CF_EXPORT const CFStringRef kCFIslamicCalendar;
203CF_EXPORT const CFStringRef kCFIslamicCivilCalendar;
204CF_EXPORT const CFStringRef kCFJapaneseCalendar;
205CF_EXPORT const CFStringRef kCFRepublicOfChinaCalendar CF_AVAILABLE(10_6, 4_0);
206CF_EXPORT const CFStringRef kCFPersianCalendar CF_AVAILABLE(10_6, 4_0);
207CF_EXPORT const CFStringRef kCFIndianCalendar CF_AVAILABLE(10_6, 4_0);
208CF_EXPORT const CFStringRef kCFISO8601Calendar CF_AVAILABLE(10_6, 4_0);
d7384798
A
209CF_EXPORT const CFStringRef kCFIslamicTabularCalendar CF_AVAILABLE(10_10, 8_0);
210CF_EXPORT const CFStringRef kCFIslamicUmmAlQuraCalendar CF_AVAILABLE(10_10, 8_0);
bd5b749c
A
211
212CF_EXTERN_C_END
856091c5 213CF_IMPLICIT_BRIDGING_DISABLED
bd5b749c 214
bd5b749c
A
215#endif /* ! __COREFOUNDATION_CFLOCALE__ */
216