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-2013, 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 35CF_IMPLICIT_BRIDGING_ENABLED 36CF_EXTERN_C_BEGIN 37 38typedef const struct __CFLocale *CFLocaleRef; 39 40CF_EXPORT 41CFTypeID CFLocaleGetTypeID(void); 42 43CF_EXPORT 44CFLocaleRef CFLocaleGetSystem(void); 45 // Returns the "root", canonical locale. Contains fixed "backstop" settings. 46 47CF_EXPORT 48CFLocaleRef 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 58CF_EXPORT 59CFArrayRef CFLocaleCopyAvailableLocaleIdentifiers(void); 60 // Returns an array of CFStrings that represents all locales for 61 // which locale data is available. 62 63CF_EXPORT 64CFArrayRef 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 69CF_EXPORT 70CFArrayRef 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 75CF_EXPORT 76CFArrayRef 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 81CF_EXPORT 82CFArrayRef 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 86CF_EXPORT 87CFArrayRef CFLocaleCopyPreferredLanguages(void) CF_AVAILABLE(10_5, 2_0); 88 // Returns the array of canonicalized CFString locale IDs that the user prefers. 89 90CF_EXPORT 91CFStringRef CFLocaleCreateCanonicalLanguageIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); 92 // Map an arbitrary language identification string (something close at 93 // least) to a canonical language identifier. 94 95CF_EXPORT 96CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromString(CFAllocatorRef allocator, CFStringRef localeIdentifier); 97 // Map an arbitrary locale identification string (something close at 98 // least) to the canonical identifier. 99 100CF_EXPORT 101CFStringRef CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes(CFAllocatorRef allocator, LangCode lcode, RegionCode rcode); 102 // Map a Mac OS LangCode and RegionCode to the canonical locale identifier. 103 104CF_EXPORT 105CFStringRef CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode(CFAllocatorRef allocator, uint32_t lcid) CF_AVAILABLE(10_6, 4_0); 106 // Map a Windows LCID to the canonical locale identifier. 107 108CF_EXPORT 109uint32_t CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier(CFStringRef localeIdentifier) CF_AVAILABLE(10_6, 4_0); 110 // Map a locale identifier to a Windows LCID. 111 112typedef CF_ENUM(CFIndex, CFLocaleLanguageDirection) { 113 kCFLocaleLanguageDirectionUnknown = 0, 114 kCFLocaleLanguageDirectionLeftToRight = 1, 115 kCFLocaleLanguageDirectionRightToLeft = 2, 116 kCFLocaleLanguageDirectionTopToBottom = 3, 117 kCFLocaleLanguageDirectionBottomToTop = 4 118}; 119 120CF_EXPORT 121CFLocaleLanguageDirection CFLocaleGetLanguageCharacterDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); 122 123CF_EXPORT 124CFLocaleLanguageDirection CFLocaleGetLanguageLineDirection(CFStringRef isoLangCode) CF_AVAILABLE(10_6, 4_0); 125 126CF_EXPORT 127CFDictionaryRef 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 136CF_EXPORT 137CFStringRef 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 144CF_EXPORT 145CFLocaleRef CFLocaleCreate(CFAllocatorRef allocator, CFStringRef localeIdentifier); 146 // Returns a CFLocaleRef for the locale named by the "arbitrary" locale identifier. 147 148CF_EXPORT 149CFLocaleRef 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 154CF_EXPORT 155CFStringRef 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 159CF_EXPORT 160CFTypeRef 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 164CF_EXPORT 165CFStringRef 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 171CF_EXPORT const CFStringRef kCFLocaleCurrentLocaleDidChangeNotification CF_AVAILABLE(10_5, 2_0); 172 173 174// Locale Keys 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); 196 197// Values for kCFLocaleCalendarIdentifier 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); 209 210CF_EXTERN_C_END 211CF_IMPLICIT_BRIDGING_DISABLED 212 213#endif /* ! __COREFOUNDATION_CFLOCALE__ */ 214 215