objc2_core_foundation/generated/
CFString.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "objc2")]
6use objc2::__framework_prelude::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstringencoding?language=objc)
11pub type CFStringEncoding = u32;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstringbuiltinencodings?language=objc)
14// NS_ENUM
15#[repr(transparent)]
16#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
17pub struct CFStringBuiltInEncodings(pub CFStringEncoding);
18impl CFStringBuiltInEncodings {
19    #[doc(alias = "kCFStringEncodingMacRoman")]
20    pub const EncodingMacRoman: Self = Self(0);
21    #[doc(alias = "kCFStringEncodingWindowsLatin1")]
22    pub const EncodingWindowsLatin1: Self = Self(0x0500);
23    #[doc(alias = "kCFStringEncodingISOLatin1")]
24    pub const EncodingISOLatin1: Self = Self(0x0201);
25    #[doc(alias = "kCFStringEncodingNextStepLatin")]
26    pub const EncodingNextStepLatin: Self = Self(0x0B01);
27    #[doc(alias = "kCFStringEncodingASCII")]
28    pub const EncodingASCII: Self = Self(0x0600);
29    #[doc(alias = "kCFStringEncodingUnicode")]
30    pub const EncodingUnicode: Self = Self(0x0100);
31    #[doc(alias = "kCFStringEncodingUTF8")]
32    pub const EncodingUTF8: Self = Self(0x08000100);
33    #[doc(alias = "kCFStringEncodingNonLossyASCII")]
34    pub const EncodingNonLossyASCII: Self = Self(0x0BFF);
35    #[doc(alias = "kCFStringEncodingUTF16")]
36    pub const EncodingUTF16: Self = Self(0x0100);
37    #[doc(alias = "kCFStringEncodingUTF16BE")]
38    pub const EncodingUTF16BE: Self = Self(0x10000100);
39    #[doc(alias = "kCFStringEncodingUTF16LE")]
40    pub const EncodingUTF16LE: Self = Self(0x14000100);
41    #[doc(alias = "kCFStringEncodingUTF32")]
42    pub const EncodingUTF32: Self = Self(0x0c000100);
43    #[doc(alias = "kCFStringEncodingUTF32BE")]
44    pub const EncodingUTF32BE: Self = Self(0x18000100);
45    #[doc(alias = "kCFStringEncodingUTF32LE")]
46    pub const EncodingUTF32LE: Self = Self(0x1c000100);
47}
48
49#[cfg(feature = "objc2")]
50unsafe impl Encode for CFStringBuiltInEncodings {
51    const ENCODING: Encoding = CFStringEncoding::ENCODING;
52}
53
54#[cfg(feature = "objc2")]
55unsafe impl RefEncode for CFStringBuiltInEncodings {
56    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59#[cfg(feature = "CFBase")]
60unsafe impl ConcreteType for CFString {
61    #[doc(alias = "CFStringGetTypeID")]
62    #[inline]
63    fn type_id() -> CFTypeID {
64        extern "C-unwind" {
65            fn CFStringGetTypeID() -> CFTypeID;
66        }
67        unsafe { CFStringGetTypeID() }
68    }
69}
70
71/// * Immutable string creation functions **
72#[cfg(feature = "CFBase")]
73#[inline]
74pub unsafe extern "C-unwind" fn CFStringCreateWithPascalString(
75    alloc: Option<&CFAllocator>,
76    p_str: ConstStr255Param,
77    encoding: CFStringEncoding,
78) -> Option<CFRetained<CFString>> {
79    extern "C-unwind" {
80        fn CFStringCreateWithPascalString(
81            alloc: Option<&CFAllocator>,
82            p_str: ConstStr255Param,
83            encoding: CFStringEncoding,
84        ) -> Option<NonNull<CFString>>;
85    }
86    let ret = unsafe { CFStringCreateWithPascalString(alloc, p_str, encoding) };
87    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
88}
89
90#[cfg(feature = "CFBase")]
91#[inline]
92pub unsafe extern "C-unwind" fn CFStringCreateWithCString(
93    alloc: Option<&CFAllocator>,
94    c_str: *const c_char,
95    encoding: CFStringEncoding,
96) -> Option<CFRetained<CFString>> {
97    extern "C-unwind" {
98        fn CFStringCreateWithCString(
99            alloc: Option<&CFAllocator>,
100            c_str: *const c_char,
101            encoding: CFStringEncoding,
102        ) -> Option<NonNull<CFString>>;
103    }
104    let ret = unsafe { CFStringCreateWithCString(alloc, c_str, encoding) };
105    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
106}
107
108#[cfg(feature = "CFBase")]
109#[inline]
110pub unsafe extern "C-unwind" fn CFStringCreateWithBytes(
111    alloc: Option<&CFAllocator>,
112    bytes: *const u8,
113    num_bytes: CFIndex,
114    encoding: CFStringEncoding,
115    is_external_representation: bool,
116) -> Option<CFRetained<CFString>> {
117    extern "C-unwind" {
118        fn CFStringCreateWithBytes(
119            alloc: Option<&CFAllocator>,
120            bytes: *const u8,
121            num_bytes: CFIndex,
122            encoding: CFStringEncoding,
123            is_external_representation: Boolean,
124        ) -> Option<NonNull<CFString>>;
125    }
126    let ret = unsafe {
127        CFStringCreateWithBytes(
128            alloc,
129            bytes,
130            num_bytes,
131            encoding,
132            is_external_representation as _,
133        )
134    };
135    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
136}
137
138#[cfg(feature = "CFBase")]
139#[inline]
140pub unsafe extern "C-unwind" fn CFStringCreateWithCharacters(
141    alloc: Option<&CFAllocator>,
142    chars: *const UniChar,
143    num_chars: CFIndex,
144) -> Option<CFRetained<CFString>> {
145    extern "C-unwind" {
146        fn CFStringCreateWithCharacters(
147            alloc: Option<&CFAllocator>,
148            chars: *const UniChar,
149            num_chars: CFIndex,
150        ) -> Option<NonNull<CFString>>;
151    }
152    let ret = unsafe { CFStringCreateWithCharacters(alloc, chars, num_chars) };
153    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
154}
155
156#[cfg(feature = "CFBase")]
157#[inline]
158pub unsafe extern "C-unwind" fn CFStringCreateWithPascalStringNoCopy(
159    alloc: Option<&CFAllocator>,
160    p_str: ConstStr255Param,
161    encoding: CFStringEncoding,
162    contents_deallocator: Option<&CFAllocator>,
163) -> Option<CFRetained<CFString>> {
164    extern "C-unwind" {
165        fn CFStringCreateWithPascalStringNoCopy(
166            alloc: Option<&CFAllocator>,
167            p_str: ConstStr255Param,
168            encoding: CFStringEncoding,
169            contents_deallocator: Option<&CFAllocator>,
170        ) -> Option<NonNull<CFString>>;
171    }
172    let ret = unsafe {
173        CFStringCreateWithPascalStringNoCopy(alloc, p_str, encoding, contents_deallocator)
174    };
175    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
176}
177
178#[cfg(feature = "CFBase")]
179#[inline]
180pub unsafe extern "C-unwind" fn CFStringCreateWithCStringNoCopy(
181    alloc: Option<&CFAllocator>,
182    c_str: *const c_char,
183    encoding: CFStringEncoding,
184    contents_deallocator: Option<&CFAllocator>,
185) -> Option<CFRetained<CFString>> {
186    extern "C-unwind" {
187        fn CFStringCreateWithCStringNoCopy(
188            alloc: Option<&CFAllocator>,
189            c_str: *const c_char,
190            encoding: CFStringEncoding,
191            contents_deallocator: Option<&CFAllocator>,
192        ) -> Option<NonNull<CFString>>;
193    }
194    let ret =
195        unsafe { CFStringCreateWithCStringNoCopy(alloc, c_str, encoding, contents_deallocator) };
196    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
197}
198
199#[cfg(feature = "CFBase")]
200#[inline]
201pub unsafe extern "C-unwind" fn CFStringCreateWithBytesNoCopy(
202    alloc: Option<&CFAllocator>,
203    bytes: *const u8,
204    num_bytes: CFIndex,
205    encoding: CFStringEncoding,
206    is_external_representation: bool,
207    contents_deallocator: Option<&CFAllocator>,
208) -> Option<CFRetained<CFString>> {
209    extern "C-unwind" {
210        fn CFStringCreateWithBytesNoCopy(
211            alloc: Option<&CFAllocator>,
212            bytes: *const u8,
213            num_bytes: CFIndex,
214            encoding: CFStringEncoding,
215            is_external_representation: Boolean,
216            contents_deallocator: Option<&CFAllocator>,
217        ) -> Option<NonNull<CFString>>;
218    }
219    let ret = unsafe {
220        CFStringCreateWithBytesNoCopy(
221            alloc,
222            bytes,
223            num_bytes,
224            encoding,
225            is_external_representation as _,
226            contents_deallocator,
227        )
228    };
229    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
230}
231
232#[cfg(feature = "CFBase")]
233#[inline]
234pub unsafe extern "C-unwind" fn CFStringCreateWithCharactersNoCopy(
235    alloc: Option<&CFAllocator>,
236    chars: *const UniChar,
237    num_chars: CFIndex,
238    contents_deallocator: Option<&CFAllocator>,
239) -> Option<CFRetained<CFString>> {
240    extern "C-unwind" {
241        fn CFStringCreateWithCharactersNoCopy(
242            alloc: Option<&CFAllocator>,
243            chars: *const UniChar,
244            num_chars: CFIndex,
245            contents_deallocator: Option<&CFAllocator>,
246        ) -> Option<NonNull<CFString>>;
247    }
248    let ret = unsafe {
249        CFStringCreateWithCharactersNoCopy(alloc, chars, num_chars, contents_deallocator)
250    };
251    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
252}
253
254#[cfg(feature = "CFBase")]
255#[inline]
256pub unsafe extern "C-unwind" fn CFStringCreateWithSubstring(
257    alloc: Option<&CFAllocator>,
258    str: Option<&CFString>,
259    range: CFRange,
260) -> Option<CFRetained<CFString>> {
261    extern "C-unwind" {
262        fn CFStringCreateWithSubstring(
263            alloc: Option<&CFAllocator>,
264            str: Option<&CFString>,
265            range: CFRange,
266        ) -> Option<NonNull<CFString>>;
267    }
268    let ret = unsafe { CFStringCreateWithSubstring(alloc, str, range) };
269    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
270}
271
272#[cfg(feature = "CFBase")]
273#[inline]
274pub unsafe extern "C-unwind" fn CFStringCreateCopy(
275    alloc: Option<&CFAllocator>,
276    the_string: Option<&CFString>,
277) -> Option<CFRetained<CFString>> {
278    extern "C-unwind" {
279        fn CFStringCreateCopy(
280            alloc: Option<&CFAllocator>,
281            the_string: Option<&CFString>,
282        ) -> Option<NonNull<CFString>>;
283    }
284    let ret = unsafe { CFStringCreateCopy(alloc, the_string) };
285    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
286}
287
288#[cfg(feature = "CFBase")]
289#[inline]
290pub unsafe extern "C-unwind" fn CFStringCreateMutable(
291    alloc: Option<&CFAllocator>,
292    max_length: CFIndex,
293) -> Option<CFRetained<CFMutableString>> {
294    extern "C-unwind" {
295        fn CFStringCreateMutable(
296            alloc: Option<&CFAllocator>,
297            max_length: CFIndex,
298        ) -> Option<NonNull<CFMutableString>>;
299    }
300    let ret = unsafe { CFStringCreateMutable(alloc, max_length) };
301    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
302}
303
304#[cfg(feature = "CFBase")]
305#[inline]
306pub unsafe extern "C-unwind" fn CFStringCreateMutableCopy(
307    alloc: Option<&CFAllocator>,
308    max_length: CFIndex,
309    the_string: Option<&CFString>,
310) -> Option<CFRetained<CFMutableString>> {
311    extern "C-unwind" {
312        fn CFStringCreateMutableCopy(
313            alloc: Option<&CFAllocator>,
314            max_length: CFIndex,
315            the_string: Option<&CFString>,
316        ) -> Option<NonNull<CFMutableString>>;
317    }
318    let ret = unsafe { CFStringCreateMutableCopy(alloc, max_length, the_string) };
319    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
320}
321
322#[cfg(feature = "CFBase")]
323#[inline]
324pub unsafe extern "C-unwind" fn CFStringCreateMutableWithExternalCharactersNoCopy(
325    alloc: Option<&CFAllocator>,
326    chars: *mut UniChar,
327    num_chars: CFIndex,
328    capacity: CFIndex,
329    external_characters_allocator: Option<&CFAllocator>,
330) -> Option<CFRetained<CFMutableString>> {
331    extern "C-unwind" {
332        fn CFStringCreateMutableWithExternalCharactersNoCopy(
333            alloc: Option<&CFAllocator>,
334            chars: *mut UniChar,
335            num_chars: CFIndex,
336            capacity: CFIndex,
337            external_characters_allocator: Option<&CFAllocator>,
338        ) -> Option<NonNull<CFMutableString>>;
339    }
340    let ret = unsafe {
341        CFStringCreateMutableWithExternalCharactersNoCopy(
342            alloc,
343            chars,
344            num_chars,
345            capacity,
346            external_characters_allocator,
347        )
348    };
349    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
350}
351
352extern "C-unwind" {
353    /// * Basic accessors for the contents **
354    #[cfg(feature = "CFBase")]
355    pub fn CFStringGetLength(the_string: &CFString) -> CFIndex;
356}
357
358extern "C-unwind" {
359    #[cfg(feature = "CFBase")]
360    pub fn CFStringGetCharacterAtIndex(the_string: &CFString, idx: CFIndex) -> UniChar;
361}
362
363extern "C-unwind" {
364    #[cfg(feature = "CFBase")]
365    pub fn CFStringGetCharacters(the_string: &CFString, range: CFRange, buffer: *mut UniChar);
366}
367
368#[cfg(feature = "CFBase")]
369#[inline]
370pub unsafe extern "C-unwind" fn CFStringGetPascalString(
371    the_string: &CFString,
372    buffer: StringPtr,
373    buffer_size: CFIndex,
374    encoding: CFStringEncoding,
375) -> bool {
376    extern "C-unwind" {
377        fn CFStringGetPascalString(
378            the_string: &CFString,
379            buffer: StringPtr,
380            buffer_size: CFIndex,
381            encoding: CFStringEncoding,
382        ) -> Boolean;
383    }
384    let ret = unsafe { CFStringGetPascalString(the_string, buffer, buffer_size, encoding) };
385    ret != 0
386}
387
388#[cfg(feature = "CFBase")]
389#[inline]
390pub unsafe extern "C-unwind" fn CFStringGetCString(
391    the_string: &CFString,
392    buffer: *mut c_char,
393    buffer_size: CFIndex,
394    encoding: CFStringEncoding,
395) -> bool {
396    extern "C-unwind" {
397        fn CFStringGetCString(
398            the_string: &CFString,
399            buffer: *mut c_char,
400            buffer_size: CFIndex,
401            encoding: CFStringEncoding,
402        ) -> Boolean;
403    }
404    let ret = unsafe { CFStringGetCString(the_string, buffer, buffer_size, encoding) };
405    ret != 0
406}
407
408extern "C-unwind" {
409    #[cfg(feature = "CFBase")]
410    pub fn CFStringGetPascalStringPtr(
411        the_string: &CFString,
412        encoding: CFStringEncoding,
413    ) -> ConstStringPtr;
414}
415
416extern "C-unwind" {
417    #[cfg(feature = "CFBase")]
418    pub fn CFStringGetCStringPtr(
419        the_string: &CFString,
420        encoding: CFStringEncoding,
421    ) -> *const c_char;
422}
423
424extern "C-unwind" {
425    #[cfg(feature = "CFBase")]
426    pub fn CFStringGetCharactersPtr(the_string: &CFString) -> *const UniChar;
427}
428
429#[cfg(feature = "CFBase")]
430#[inline]
431pub unsafe extern "C-unwind" fn CFStringGetBytes(
432    the_string: &CFString,
433    range: CFRange,
434    encoding: CFStringEncoding,
435    loss_byte: u8,
436    is_external_representation: bool,
437    buffer: *mut u8,
438    max_buf_len: CFIndex,
439    used_buf_len: *mut CFIndex,
440) -> CFIndex {
441    extern "C-unwind" {
442        fn CFStringGetBytes(
443            the_string: &CFString,
444            range: CFRange,
445            encoding: CFStringEncoding,
446            loss_byte: u8,
447            is_external_representation: Boolean,
448            buffer: *mut u8,
449            max_buf_len: CFIndex,
450            used_buf_len: *mut CFIndex,
451        ) -> CFIndex;
452    }
453    unsafe {
454        CFStringGetBytes(
455            the_string,
456            range,
457            encoding,
458            loss_byte,
459            is_external_representation as _,
460            buffer,
461            max_buf_len,
462            used_buf_len,
463        )
464    }
465}
466
467#[cfg(all(feature = "CFBase", feature = "CFData"))]
468#[inline]
469pub unsafe extern "C-unwind" fn CFStringCreateFromExternalRepresentation(
470    alloc: Option<&CFAllocator>,
471    data: Option<&CFData>,
472    encoding: CFStringEncoding,
473) -> Option<CFRetained<CFString>> {
474    extern "C-unwind" {
475        fn CFStringCreateFromExternalRepresentation(
476            alloc: Option<&CFAllocator>,
477            data: Option<&CFData>,
478            encoding: CFStringEncoding,
479        ) -> Option<NonNull<CFString>>;
480    }
481    let ret = unsafe { CFStringCreateFromExternalRepresentation(alloc, data, encoding) };
482    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
483}
484
485#[cfg(all(feature = "CFBase", feature = "CFData"))]
486#[inline]
487pub unsafe extern "C-unwind" fn CFStringCreateExternalRepresentation(
488    alloc: Option<&CFAllocator>,
489    the_string: Option<&CFString>,
490    encoding: CFStringEncoding,
491    loss_byte: u8,
492) -> Option<CFRetained<CFData>> {
493    extern "C-unwind" {
494        fn CFStringCreateExternalRepresentation(
495            alloc: Option<&CFAllocator>,
496            the_string: Option<&CFString>,
497            encoding: CFStringEncoding,
498            loss_byte: u8,
499        ) -> Option<NonNull<CFData>>;
500    }
501    let ret =
502        unsafe { CFStringCreateExternalRepresentation(alloc, the_string, encoding, loss_byte) };
503    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
504}
505
506extern "C-unwind" {
507    #[cfg(feature = "CFBase")]
508    pub fn CFStringGetSmallestEncoding(the_string: &CFString) -> CFStringEncoding;
509}
510
511extern "C-unwind" {
512    #[cfg(feature = "CFBase")]
513    pub fn CFStringGetFastestEncoding(the_string: &CFString) -> CFStringEncoding;
514}
515
516extern "C-unwind" {
517    pub fn CFStringGetSystemEncoding() -> CFStringEncoding;
518}
519
520extern "C-unwind" {
521    #[cfg(feature = "CFBase")]
522    pub fn CFStringGetMaximumSizeForEncoding(
523        length: CFIndex,
524        encoding: CFStringEncoding,
525    ) -> CFIndex;
526}
527
528/// * FileSystem path conversion functions **
529#[cfg(feature = "CFBase")]
530#[inline]
531pub unsafe extern "C-unwind" fn CFStringGetFileSystemRepresentation(
532    string: &CFString,
533    buffer: *mut c_char,
534    max_buf_len: CFIndex,
535) -> bool {
536    extern "C-unwind" {
537        fn CFStringGetFileSystemRepresentation(
538            string: &CFString,
539            buffer: *mut c_char,
540            max_buf_len: CFIndex,
541        ) -> Boolean;
542    }
543    let ret = unsafe { CFStringGetFileSystemRepresentation(string, buffer, max_buf_len) };
544    ret != 0
545}
546
547extern "C-unwind" {
548    #[cfg(feature = "CFBase")]
549    pub fn CFStringGetMaximumSizeOfFileSystemRepresentation(string: &CFString) -> CFIndex;
550}
551
552#[cfg(feature = "CFBase")]
553#[inline]
554pub unsafe extern "C-unwind" fn CFStringCreateWithFileSystemRepresentation(
555    alloc: Option<&CFAllocator>,
556    buffer: *const c_char,
557) -> Option<CFRetained<CFString>> {
558    extern "C-unwind" {
559        fn CFStringCreateWithFileSystemRepresentation(
560            alloc: Option<&CFAllocator>,
561            buffer: *const c_char,
562        ) -> Option<NonNull<CFString>>;
563    }
564    let ret = unsafe { CFStringCreateWithFileSystemRepresentation(alloc, buffer) };
565    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
566}
567
568/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstringcompareflags?language=objc)
569// NS_OPTIONS
570#[cfg(feature = "CFBase")]
571#[repr(transparent)]
572#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
573pub struct CFStringCompareFlags(pub CFOptionFlags);
574#[cfg(feature = "CFBase")]
575bitflags::bitflags! {
576    impl CFStringCompareFlags: CFOptionFlags {
577        #[doc(alias = "kCFCompareCaseInsensitive")]
578        const CompareCaseInsensitive = 1;
579        #[doc(alias = "kCFCompareBackwards")]
580        const CompareBackwards = 4;
581        #[doc(alias = "kCFCompareAnchored")]
582        const CompareAnchored = 8;
583        #[doc(alias = "kCFCompareNonliteral")]
584        const CompareNonliteral = 16;
585        #[doc(alias = "kCFCompareLocalized")]
586        const CompareLocalized = 32;
587        #[doc(alias = "kCFCompareNumerically")]
588        const CompareNumerically = 64;
589        #[doc(alias = "kCFCompareDiacriticInsensitive")]
590        const CompareDiacriticInsensitive = 128;
591        #[doc(alias = "kCFCompareWidthInsensitive")]
592        const CompareWidthInsensitive = 256;
593        #[doc(alias = "kCFCompareForcedOrdering")]
594        const CompareForcedOrdering = 512;
595    }
596}
597
598#[cfg(all(feature = "CFBase", feature = "objc2"))]
599unsafe impl Encode for CFStringCompareFlags {
600    const ENCODING: Encoding = CFOptionFlags::ENCODING;
601}
602
603#[cfg(all(feature = "CFBase", feature = "objc2"))]
604unsafe impl RefEncode for CFStringCompareFlags {
605    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
606}
607
608extern "C-unwind" {
609    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
610    pub fn CFStringCompareWithOptionsAndLocale(
611        the_string1: &CFString,
612        the_string2: Option<&CFString>,
613        range_to_compare: CFRange,
614        compare_options: CFStringCompareFlags,
615        locale: Option<&CFLocale>,
616    ) -> CFComparisonResult;
617}
618
619extern "C-unwind" {
620    #[cfg(feature = "CFBase")]
621    pub fn CFStringCompareWithOptions(
622        the_string1: &CFString,
623        the_string2: Option<&CFString>,
624        range_to_compare: CFRange,
625        compare_options: CFStringCompareFlags,
626    ) -> CFComparisonResult;
627}
628
629extern "C-unwind" {
630    #[cfg(feature = "CFBase")]
631    pub fn CFStringCompare(
632        the_string1: &CFString,
633        the_string2: Option<&CFString>,
634        compare_options: CFStringCompareFlags,
635    ) -> CFComparisonResult;
636}
637
638#[cfg(all(feature = "CFBase", feature = "CFLocale"))]
639#[inline]
640pub unsafe extern "C-unwind" fn CFStringFindWithOptionsAndLocale(
641    the_string: &CFString,
642    string_to_find: Option<&CFString>,
643    range_to_search: CFRange,
644    search_options: CFStringCompareFlags,
645    locale: Option<&CFLocale>,
646    result: *mut CFRange,
647) -> bool {
648    extern "C-unwind" {
649        fn CFStringFindWithOptionsAndLocale(
650            the_string: &CFString,
651            string_to_find: Option<&CFString>,
652            range_to_search: CFRange,
653            search_options: CFStringCompareFlags,
654            locale: Option<&CFLocale>,
655            result: *mut CFRange,
656        ) -> Boolean;
657    }
658    let ret = unsafe {
659        CFStringFindWithOptionsAndLocale(
660            the_string,
661            string_to_find,
662            range_to_search,
663            search_options,
664            locale,
665            result,
666        )
667    };
668    ret != 0
669}
670
671#[cfg(feature = "CFBase")]
672#[inline]
673pub unsafe extern "C-unwind" fn CFStringFindWithOptions(
674    the_string: &CFString,
675    string_to_find: Option<&CFString>,
676    range_to_search: CFRange,
677    search_options: CFStringCompareFlags,
678    result: *mut CFRange,
679) -> bool {
680    extern "C-unwind" {
681        fn CFStringFindWithOptions(
682            the_string: &CFString,
683            string_to_find: Option<&CFString>,
684            range_to_search: CFRange,
685            search_options: CFStringCompareFlags,
686            result: *mut CFRange,
687        ) -> Boolean;
688    }
689    let ret = unsafe {
690        CFStringFindWithOptions(
691            the_string,
692            string_to_find,
693            range_to_search,
694            search_options,
695            result,
696        )
697    };
698    ret != 0
699}
700
701#[cfg(all(feature = "CFArray", feature = "CFBase"))]
702#[inline]
703pub unsafe extern "C-unwind" fn CFStringCreateArrayWithFindResults(
704    alloc: Option<&CFAllocator>,
705    the_string: Option<&CFString>,
706    string_to_find: Option<&CFString>,
707    range_to_search: CFRange,
708    compare_options: CFStringCompareFlags,
709) -> Option<CFRetained<CFArray>> {
710    extern "C-unwind" {
711        fn CFStringCreateArrayWithFindResults(
712            alloc: Option<&CFAllocator>,
713            the_string: Option<&CFString>,
714            string_to_find: Option<&CFString>,
715            range_to_search: CFRange,
716            compare_options: CFStringCompareFlags,
717        ) -> Option<NonNull<CFArray>>;
718    }
719    let ret = unsafe {
720        CFStringCreateArrayWithFindResults(
721            alloc,
722            the_string,
723            string_to_find,
724            range_to_search,
725            compare_options,
726        )
727    };
728    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
729}
730
731extern "C-unwind" {
732    #[cfg(feature = "CFBase")]
733    pub fn CFStringFind(
734        the_string: &CFString,
735        string_to_find: Option<&CFString>,
736        compare_options: CFStringCompareFlags,
737    ) -> CFRange;
738}
739
740#[cfg(feature = "CFBase")]
741#[inline]
742pub unsafe extern "C-unwind" fn CFStringHasPrefix(
743    the_string: &CFString,
744    prefix: Option<&CFString>,
745) -> bool {
746    extern "C-unwind" {
747        fn CFStringHasPrefix(the_string: &CFString, prefix: Option<&CFString>) -> Boolean;
748    }
749    let ret = unsafe { CFStringHasPrefix(the_string, prefix) };
750    ret != 0
751}
752
753#[cfg(feature = "CFBase")]
754#[inline]
755pub unsafe extern "C-unwind" fn CFStringHasSuffix(
756    the_string: &CFString,
757    suffix: Option<&CFString>,
758) -> bool {
759    extern "C-unwind" {
760        fn CFStringHasSuffix(the_string: &CFString, suffix: Option<&CFString>) -> Boolean;
761    }
762    let ret = unsafe { CFStringHasSuffix(the_string, suffix) };
763    ret != 0
764}
765
766extern "C-unwind" {
767    /// Returns the range of the composed character sequence at the specified index.
768    ///
769    /// Parameter `theString`: The CFString which is to be searched.  If this
770    /// parameter is not a valid CFString, the behavior is
771    /// undefined.
772    ///
773    /// Parameter `theIndex`: The index of the character contained in the
774    /// composed character sequence.  If the index is
775    /// outside the index space of the string (0 to N-1 inclusive,
776    /// where N is the length of the string), the behavior is
777    /// undefined.
778    ///
779    /// Returns: The range of the composed character sequence.
780    #[cfg(feature = "CFBase")]
781    pub fn CFStringGetRangeOfComposedCharactersAtIndex(
782        the_string: &CFString,
783        the_index: CFIndex,
784    ) -> CFRange;
785}
786
787/// Query the range of the first character contained in the specified character set.
788///
789/// Parameter `theString`: The CFString which is to be searched.  If this
790/// parameter is not a valid CFString, the behavior is
791/// undefined.
792///
793/// Parameter `theSet`: The CFCharacterSet against which the membership
794/// of characters is checked.  If this parameter is not a valid
795/// CFCharacterSet, the behavior is undefined.
796///
797/// Parameter `rangeToSearch`: The range of characters within the string to search. If
798/// the range location or end point (defined by the location
799/// plus length minus 1) are outside the index space of the
800/// string (0 to N-1 inclusive, where N is the length of the
801/// string), the behavior is undefined. If the range length is
802/// negative, the behavior is undefined. The range may be empty
803/// (length 0), in which case no search is performed.
804///
805/// Parameter `searchOptions`: The bitwise-or'ed option flags to control
806/// the search behavior.  The supported options are
807/// kCFCompareBackwards andkCFCompareAnchored.
808/// If other option flags are specified, the behavior
809/// is undefined.
810///
811/// Parameter `result`: The pointer to a CFRange supplied by the caller in
812/// which the search result is stored.  Note that the length
813/// of this range can be more than 1, if for instance the
814/// result is a composed character. If a pointer to an invalid
815/// memory is specified, the behavior is undefined.
816///
817/// Returns: true, if at least a character which is a member of the character
818/// set is found and result is filled, otherwise, false.
819#[cfg(all(feature = "CFBase", feature = "CFCharacterSet"))]
820#[inline]
821pub unsafe extern "C-unwind" fn CFStringFindCharacterFromSet(
822    the_string: &CFString,
823    the_set: Option<&CFCharacterSet>,
824    range_to_search: CFRange,
825    search_options: CFStringCompareFlags,
826    result: *mut CFRange,
827) -> bool {
828    extern "C-unwind" {
829        fn CFStringFindCharacterFromSet(
830            the_string: &CFString,
831            the_set: Option<&CFCharacterSet>,
832            range_to_search: CFRange,
833            search_options: CFStringCompareFlags,
834            result: *mut CFRange,
835        ) -> Boolean;
836    }
837    let ret = unsafe {
838        CFStringFindCharacterFromSet(the_string, the_set, range_to_search, search_options, result)
839    };
840    ret != 0
841}
842
843extern "C-unwind" {
844    #[cfg(feature = "CFBase")]
845    pub fn CFStringGetLineBounds(
846        the_string: &CFString,
847        range: CFRange,
848        line_begin_index: *mut CFIndex,
849        line_end_index: *mut CFIndex,
850        contents_end_index: *mut CFIndex,
851    );
852}
853
854extern "C-unwind" {
855    #[cfg(feature = "CFBase")]
856    pub fn CFStringGetParagraphBounds(
857        string: &CFString,
858        range: CFRange,
859        par_begin_index: *mut CFIndex,
860        par_end_index: *mut CFIndex,
861        contents_end_index: *mut CFIndex,
862    );
863}
864
865extern "C-unwind" {
866    /// Retrieve the first potential hyphenation location found before the specified location.
867    ///
868    /// Parameter `string`: The CFString which is to be hyphenated.  If this
869    /// parameter is not a valid CFString, the behavior is
870    /// undefined.
871    ///
872    /// Parameter `location`: An index in the string.  If a valid hyphen index is returned, it
873    /// will be before this index.
874    ///
875    /// Parameter `limitRange`: The range of characters within the string to search. If
876    /// the range location or end point (defined by the location
877    /// plus length minus 1) are outside the index space of the
878    /// string (0 to N-1 inclusive, where N is the length of the
879    /// string), the behavior is undefined. If the range length is
880    /// negative, the behavior is undefined. The range may be empty
881    /// (length 0), in which case no hyphen location is generated.
882    ///
883    /// Parameter `options`: Reserved for future use.
884    ///
885    /// Parameter `locale`: Specifies which language's hyphenation conventions to use.
886    /// This must be a valid locale.  Hyphenation data is not available
887    /// for all locales.  You can use CFStringIsHyphenationAvailableForLocale
888    /// to test for availability of hyphenation data.
889    ///
890    /// Parameter `character`: The suggested hyphen character to insert.  Pass NULL if you
891    /// do not need this information.
892    ///
893    /// Returns: an index in the string where it is appropriate to insert a hyphen, if
894    /// one exists; else kCFNotFound
895    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
896    pub fn CFStringGetHyphenationLocationBeforeIndex(
897        string: &CFString,
898        location: CFIndex,
899        limit_range: CFRange,
900        options: CFOptionFlags,
901        locale: Option<&CFLocale>,
902        character: *mut UTF32Char,
903    ) -> CFIndex;
904}
905
906#[cfg(feature = "CFLocale")]
907#[inline]
908pub unsafe extern "C-unwind" fn CFStringIsHyphenationAvailableForLocale(
909    locale: Option<&CFLocale>,
910) -> bool {
911    extern "C-unwind" {
912        fn CFStringIsHyphenationAvailableForLocale(locale: Option<&CFLocale>) -> Boolean;
913    }
914    let ret = unsafe { CFStringIsHyphenationAvailableForLocale(locale) };
915    ret != 0
916}
917
918/// * Exploding and joining strings with a separator string **
919#[cfg(all(feature = "CFArray", feature = "CFBase"))]
920#[inline]
921pub unsafe extern "C-unwind" fn CFStringCreateByCombiningStrings(
922    alloc: Option<&CFAllocator>,
923    the_array: Option<&CFArray>,
924    separator_string: Option<&CFString>,
925) -> Option<CFRetained<CFString>> {
926    extern "C-unwind" {
927        fn CFStringCreateByCombiningStrings(
928            alloc: Option<&CFAllocator>,
929            the_array: Option<&CFArray>,
930            separator_string: Option<&CFString>,
931        ) -> Option<NonNull<CFString>>;
932    }
933    let ret = unsafe { CFStringCreateByCombiningStrings(alloc, the_array, separator_string) };
934    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
935}
936
937#[cfg(all(feature = "CFArray", feature = "CFBase"))]
938#[inline]
939pub unsafe extern "C-unwind" fn CFStringCreateArrayBySeparatingStrings(
940    alloc: Option<&CFAllocator>,
941    the_string: Option<&CFString>,
942    separator_string: Option<&CFString>,
943) -> Option<CFRetained<CFArray>> {
944    extern "C-unwind" {
945        fn CFStringCreateArrayBySeparatingStrings(
946            alloc: Option<&CFAllocator>,
947            the_string: Option<&CFString>,
948            separator_string: Option<&CFString>,
949        ) -> Option<NonNull<CFArray>>;
950    }
951    let ret =
952        unsafe { CFStringCreateArrayBySeparatingStrings(alloc, the_string, separator_string) };
953    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
954}
955
956extern "C-unwind" {
957    /// * Parsing non-localized numbers from strings **
958    #[cfg(feature = "CFBase")]
959    pub fn CFStringGetIntValue(str: &CFString) -> i32;
960}
961
962extern "C-unwind" {
963    #[cfg(feature = "CFBase")]
964    pub fn CFStringGetDoubleValue(str: &CFString) -> c_double;
965}
966
967extern "C-unwind" {
968    /// * MutableString functions **
969    #[cfg(feature = "CFBase")]
970    pub fn CFStringAppend(the_string: Option<&CFMutableString>, appended_string: Option<&CFString>);
971}
972
973extern "C-unwind" {
974    #[cfg(feature = "CFBase")]
975    pub fn CFStringAppendCharacters(
976        the_string: Option<&CFMutableString>,
977        chars: *const UniChar,
978        num_chars: CFIndex,
979    );
980}
981
982extern "C-unwind" {
983    #[cfg(feature = "CFBase")]
984    pub fn CFStringAppendPascalString(
985        the_string: Option<&CFMutableString>,
986        p_str: ConstStr255Param,
987        encoding: CFStringEncoding,
988    );
989}
990
991extern "C-unwind" {
992    #[cfg(feature = "CFBase")]
993    pub fn CFStringAppendCString(
994        the_string: Option<&CFMutableString>,
995        c_str: *const c_char,
996        encoding: CFStringEncoding,
997    );
998}
999
1000extern "C-unwind" {
1001    #[cfg(feature = "CFBase")]
1002    pub fn CFStringInsert(
1003        str: Option<&CFMutableString>,
1004        idx: CFIndex,
1005        inserted_str: Option<&CFString>,
1006    );
1007}
1008
1009extern "C-unwind" {
1010    #[cfg(feature = "CFBase")]
1011    pub fn CFStringDelete(the_string: Option<&CFMutableString>, range: CFRange);
1012}
1013
1014extern "C-unwind" {
1015    #[cfg(feature = "CFBase")]
1016    pub fn CFStringReplace(
1017        the_string: Option<&CFMutableString>,
1018        range: CFRange,
1019        replacement: Option<&CFString>,
1020    );
1021}
1022
1023extern "C-unwind" {
1024    #[cfg(feature = "CFBase")]
1025    pub fn CFStringReplaceAll(the_string: Option<&CFMutableString>, replacement: Option<&CFString>);
1026}
1027
1028extern "C-unwind" {
1029    #[cfg(feature = "CFBase")]
1030    pub fn CFStringFindAndReplace(
1031        the_string: Option<&CFMutableString>,
1032        string_to_find: Option<&CFString>,
1033        replacement_string: Option<&CFString>,
1034        range_to_search: CFRange,
1035        compare_options: CFStringCompareFlags,
1036    ) -> CFIndex;
1037}
1038
1039extern "C-unwind" {
1040    #[cfg(feature = "CFBase")]
1041    pub fn CFStringSetExternalCharactersNoCopy(
1042        the_string: Option<&CFMutableString>,
1043        chars: *mut UniChar,
1044        length: CFIndex,
1045        capacity: CFIndex,
1046    );
1047}
1048
1049extern "C-unwind" {
1050    #[cfg(feature = "CFBase")]
1051    pub fn CFStringPad(
1052        the_string: Option<&CFMutableString>,
1053        pad_string: Option<&CFString>,
1054        length: CFIndex,
1055        index_into_pad: CFIndex,
1056    );
1057}
1058
1059extern "C-unwind" {
1060    #[cfg(feature = "CFBase")]
1061    pub fn CFStringTrim(the_string: Option<&CFMutableString>, trim_string: Option<&CFString>);
1062}
1063
1064extern "C-unwind" {
1065    #[cfg(feature = "CFBase")]
1066    pub fn CFStringTrimWhitespace(the_string: Option<&CFMutableString>);
1067}
1068
1069extern "C-unwind" {
1070    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
1071    pub fn CFStringLowercase(the_string: Option<&CFMutableString>, locale: Option<&CFLocale>);
1072}
1073
1074extern "C-unwind" {
1075    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
1076    pub fn CFStringUppercase(the_string: Option<&CFMutableString>, locale: Option<&CFLocale>);
1077}
1078
1079extern "C-unwind" {
1080    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
1081    pub fn CFStringCapitalize(the_string: Option<&CFMutableString>, locale: Option<&CFLocale>);
1082}
1083
1084/// This is the type of Unicode normalization forms as described in
1085/// Unicode Technical Report #15. To normalize for use with file
1086/// system calls, use CFStringGetFileSystemRepresentation().
1087///
1088/// See also [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstringnormalizationform?language=objc)
1089// NS_ENUM
1090#[cfg(feature = "CFBase")]
1091#[repr(transparent)]
1092#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
1093pub struct CFStringNormalizationForm(pub CFIndex);
1094#[cfg(feature = "CFBase")]
1095impl CFStringNormalizationForm {
1096    #[doc(alias = "kCFStringNormalizationFormD")]
1097    pub const D: Self = Self(0);
1098    #[doc(alias = "kCFStringNormalizationFormKD")]
1099    pub const KD: Self = Self(1);
1100    #[doc(alias = "kCFStringNormalizationFormC")]
1101    pub const C: Self = Self(2);
1102    #[doc(alias = "kCFStringNormalizationFormKC")]
1103    pub const KC: Self = Self(3);
1104}
1105
1106#[cfg(all(feature = "CFBase", feature = "objc2"))]
1107unsafe impl Encode for CFStringNormalizationForm {
1108    const ENCODING: Encoding = CFIndex::ENCODING;
1109}
1110
1111#[cfg(all(feature = "CFBase", feature = "objc2"))]
1112unsafe impl RefEncode for CFStringNormalizationForm {
1113    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1114}
1115
1116extern "C-unwind" {
1117    /// Normalizes the string into the specified form as described in
1118    /// Unicode Technical Report #15.
1119    ///
1120    /// Parameter `theString`: The string which is to be normalized.  If this
1121    /// parameter is not a valid mutable CFString, the behavior is
1122    /// undefined.
1123    ///
1124    /// Parameter `theForm`: The form into which the string is to be normalized.
1125    /// If this parameter is not a valid CFStringNormalizationForm value,
1126    /// the behavior is undefined.
1127    #[cfg(feature = "CFBase")]
1128    pub fn CFStringNormalize(
1129        the_string: Option<&CFMutableString>,
1130        the_form: CFStringNormalizationForm,
1131    );
1132}
1133
1134extern "C-unwind" {
1135    /// Folds the string into the form specified by the flags.
1136    /// Character foldings are operations that convert any of a set of characters
1137    /// sharing similar semantics into a single representative from that set.
1138    /// This function can be used to preprocess strings that are to be compared,
1139    /// searched, or indexed.
1140    /// Note that folding does not include normalization, so it is necessary
1141    /// to use CFStringNormalize in addition to CFStringFold in order to obtain
1142    /// the effect of kCFCompareNonliteral.
1143    ///
1144    /// Parameter `theString`: The string which is to be folded.  If this parameter is not
1145    /// a valid mutable CFString, the behavior is undefined.
1146    ///
1147    /// Parameter `theFlags`: The equivalency flags which describes the character folding form.
1148    /// Only those flags containing the word "insensitive" are recognized here; other flags are ignored.
1149    /// Folding with kCFCompareCaseInsensitive removes case distinctions in accordance with the mapping
1150    /// specified by ftp://ftp.unicode.org/Public/UNIDATA/CaseFolding.txt.  Folding with
1151    /// kCFCompareDiacriticInsensitive removes distinctions of accents and other diacritics.  Folding
1152    /// with kCFCompareWidthInsensitive removes character width distinctions by mapping characters in
1153    /// the range U+FF00-U+FFEF to their ordinary equivalents.
1154    ///
1155    /// Parameter `theLocale`: The locale tailoring the character folding behavior. If NULL,
1156    /// it's considered to be the system locale returned from CFLocaleGetSystem().
1157    /// If non-NULL and not a valid CFLocale object, the behavior is undefined.
1158    #[cfg(all(feature = "CFBase", feature = "CFLocale"))]
1159    pub fn CFStringFold(
1160        the_string: Option<&CFMutableString>,
1161        the_flags: CFStringCompareFlags,
1162        the_locale: Option<&CFLocale>,
1163    );
1164}
1165
1166#[cfg(feature = "CFBase")]
1167#[inline]
1168pub unsafe extern "C-unwind" fn CFStringTransform(
1169    string: Option<&CFMutableString>,
1170    range: *mut CFRange,
1171    transform: Option<&CFString>,
1172    reverse: bool,
1173) -> bool {
1174    extern "C-unwind" {
1175        fn CFStringTransform(
1176            string: Option<&CFMutableString>,
1177            range: *mut CFRange,
1178            transform: Option<&CFString>,
1179            reverse: Boolean,
1180        ) -> Boolean;
1181    }
1182    let ret = unsafe { CFStringTransform(string, range, transform, reverse as _) };
1183    ret != 0
1184}
1185
1186extern "C" {
1187    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformstripcombiningmarks?language=objc)
1188    #[cfg(feature = "CFBase")]
1189    pub static kCFStringTransformStripCombiningMarks: Option<&'static CFString>;
1190}
1191
1192extern "C" {
1193    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformtolatin?language=objc)
1194    #[cfg(feature = "CFBase")]
1195    pub static kCFStringTransformToLatin: Option<&'static CFString>;
1196}
1197
1198extern "C" {
1199    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformfullwidthhalfwidth?language=objc)
1200    #[cfg(feature = "CFBase")]
1201    pub static kCFStringTransformFullwidthHalfwidth: Option<&'static CFString>;
1202}
1203
1204extern "C" {
1205    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinkatakana?language=objc)
1206    #[cfg(feature = "CFBase")]
1207    pub static kCFStringTransformLatinKatakana: Option<&'static CFString>;
1208}
1209
1210extern "C" {
1211    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinhiragana?language=objc)
1212    #[cfg(feature = "CFBase")]
1213    pub static kCFStringTransformLatinHiragana: Option<&'static CFString>;
1214}
1215
1216extern "C" {
1217    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformhiraganakatakana?language=objc)
1218    #[cfg(feature = "CFBase")]
1219    pub static kCFStringTransformHiraganaKatakana: Option<&'static CFString>;
1220}
1221
1222extern "C" {
1223    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformmandarinlatin?language=objc)
1224    #[cfg(feature = "CFBase")]
1225    pub static kCFStringTransformMandarinLatin: Option<&'static CFString>;
1226}
1227
1228extern "C" {
1229    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinhangul?language=objc)
1230    #[cfg(feature = "CFBase")]
1231    pub static kCFStringTransformLatinHangul: Option<&'static CFString>;
1232}
1233
1234extern "C" {
1235    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinarabic?language=objc)
1236    #[cfg(feature = "CFBase")]
1237    pub static kCFStringTransformLatinArabic: Option<&'static CFString>;
1238}
1239
1240extern "C" {
1241    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinhebrew?language=objc)
1242    #[cfg(feature = "CFBase")]
1243    pub static kCFStringTransformLatinHebrew: Option<&'static CFString>;
1244}
1245
1246extern "C" {
1247    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatinthai?language=objc)
1248    #[cfg(feature = "CFBase")]
1249    pub static kCFStringTransformLatinThai: Option<&'static CFString>;
1250}
1251
1252extern "C" {
1253    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatincyrillic?language=objc)
1254    #[cfg(feature = "CFBase")]
1255    pub static kCFStringTransformLatinCyrillic: Option<&'static CFString>;
1256}
1257
1258extern "C" {
1259    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformlatingreek?language=objc)
1260    #[cfg(feature = "CFBase")]
1261    pub static kCFStringTransformLatinGreek: Option<&'static CFString>;
1262}
1263
1264extern "C" {
1265    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformtoxmlhex?language=objc)
1266    #[cfg(feature = "CFBase")]
1267    pub static kCFStringTransformToXMLHex: Option<&'static CFString>;
1268}
1269
1270extern "C" {
1271    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformtounicodename?language=objc)
1272    #[cfg(feature = "CFBase")]
1273    pub static kCFStringTransformToUnicodeName: Option<&'static CFString>;
1274}
1275
1276extern "C" {
1277    /// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/kcfstringtransformstripdiacritics?language=objc)
1278    #[cfg(feature = "CFBase")]
1279    pub static kCFStringTransformStripDiacritics: Option<&'static CFString>;
1280}
1281
1282/// * General encoding related functionality **
1283#[inline]
1284pub unsafe extern "C-unwind" fn CFStringIsEncodingAvailable(encoding: CFStringEncoding) -> bool {
1285    extern "C-unwind" {
1286        fn CFStringIsEncodingAvailable(encoding: CFStringEncoding) -> Boolean;
1287    }
1288    let ret = unsafe { CFStringIsEncodingAvailable(encoding) };
1289    ret != 0
1290}
1291
1292extern "C-unwind" {
1293    pub fn CFStringGetListOfAvailableEncodings() -> *const CFStringEncoding;
1294}
1295
1296#[cfg(feature = "CFBase")]
1297#[inline]
1298pub unsafe extern "C-unwind" fn CFStringGetNameOfEncoding(
1299    encoding: CFStringEncoding,
1300) -> Option<CFRetained<CFString>> {
1301    extern "C-unwind" {
1302        fn CFStringGetNameOfEncoding(encoding: CFStringEncoding) -> Option<NonNull<CFString>>;
1303    }
1304    let ret = unsafe { CFStringGetNameOfEncoding(encoding) };
1305    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1306}
1307
1308extern "C-unwind" {
1309    pub fn CFStringConvertEncodingToNSStringEncoding(encoding: CFStringEncoding) -> c_ulong;
1310}
1311
1312extern "C-unwind" {
1313    pub fn CFStringConvertNSStringEncodingToEncoding(encoding: c_ulong) -> CFStringEncoding;
1314}
1315
1316extern "C-unwind" {
1317    pub fn CFStringConvertEncodingToWindowsCodepage(encoding: CFStringEncoding) -> u32;
1318}
1319
1320extern "C-unwind" {
1321    pub fn CFStringConvertWindowsCodepageToEncoding(codepage: u32) -> CFStringEncoding;
1322}
1323
1324extern "C-unwind" {
1325    #[cfg(feature = "CFBase")]
1326    pub fn CFStringConvertIANACharSetNameToEncoding(the_string: &CFString) -> CFStringEncoding;
1327}
1328
1329#[cfg(feature = "CFBase")]
1330#[inline]
1331pub unsafe extern "C-unwind" fn CFStringConvertEncodingToIANACharSetName(
1332    encoding: CFStringEncoding,
1333) -> Option<CFRetained<CFString>> {
1334    extern "C-unwind" {
1335        fn CFStringConvertEncodingToIANACharSetName(
1336            encoding: CFStringEncoding,
1337        ) -> Option<NonNull<CFString>>;
1338    }
1339    let ret = unsafe { CFStringConvertEncodingToIANACharSetName(encoding) };
1340    ret.map(|ret| unsafe { CFRetained::retain(ret) })
1341}
1342
1343extern "C-unwind" {
1344    pub fn CFStringGetMostCompatibleMacStringEncoding(
1345        encoding: CFStringEncoding,
1346    ) -> CFStringEncoding;
1347}
1348
1349/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfstringinlinebuffer?language=objc)
1350#[cfg(feature = "CFBase")]
1351#[repr(C)]
1352#[derive(Clone, Copy, Debug, PartialEq)]
1353pub struct CFStringInlineBuffer {
1354    pub buffer: [UniChar; 64],
1355    pub theString: *const CFString,
1356    pub directUniCharBuffer: *const UniChar,
1357    pub directCStringBuffer: *const c_char,
1358    pub rangeToBuffer: CFRange,
1359    pub bufferedRangeStart: CFIndex,
1360    pub bufferedRangeEnd: CFIndex,
1361}
1362
1363#[cfg(all(feature = "CFBase", feature = "objc2"))]
1364unsafe impl Encode for CFStringInlineBuffer {
1365    const ENCODING: Encoding = Encoding::Struct(
1366        "?",
1367        &[
1368            <[UniChar; 64]>::ENCODING,
1369            <*const CFString>::ENCODING,
1370            <*const UniChar>::ENCODING,
1371            <*const c_char>::ENCODING,
1372            <CFRange>::ENCODING,
1373            <CFIndex>::ENCODING,
1374            <CFIndex>::ENCODING,
1375        ],
1376    );
1377}
1378
1379#[cfg(all(feature = "CFBase", feature = "objc2"))]
1380unsafe impl RefEncode for CFStringInlineBuffer {
1381    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
1382}
1383
1384// TODO: pub fn CFStringInitInlineBuffer(str: &CFString,buf: *mut CFStringInlineBuffer,range: CFRange,);
1385
1386// TODO: pub fn CFStringGetCharacterFromInlineBuffer(buf: *mut CFStringInlineBuffer,idx: CFIndex,) -> UniChar;
1387
1388// TODO: pub fn CFStringIsSurrogateHighCharacter(character: UniChar,) -> Boolean;
1389
1390// TODO: pub fn CFStringIsSurrogateLowCharacter(character: UniChar,) -> Boolean;
1391
1392// TODO: pub fn CFStringGetLongCharacterForSurrogatePair(surrogate_high: UniChar,surrogate_low: UniChar,) -> UTF32Char;
1393
1394// TODO: pub fn CFStringGetSurrogatePairForLongCharacter(character: UTF32Char,surrogates: *mut UniChar,) -> Boolean;
1395
1396extern "C-unwind" {
1397    #[cfg(feature = "CFBase")]
1398    pub fn CFShow(obj: Option<&CFType>);
1399}
1400
1401extern "C-unwind" {
1402    #[cfg(feature = "CFBase")]
1403    pub fn CFShowStr(str: Option<&CFString>);
1404}