| 1 | /* |
| 2 | * Copyright (C) 2018-2025 Muhammad Tayyab Akram |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _SB_PUBLIC_CODEPOINT_H |
| 18 | #define _SB_PUBLIC_CODEPOINT_Hcxx . . $ `Headers/SheenBidi/SBCodepoint.h:18:9`! |
| 19 | |
| 20 | #include <SheenBidi/SBBase.h>cxx . . $ `<file>/Headers/SheenBidi/SBBase.h`/ |
| 21 | #include <SheenBidi/SBBidiType.h>cxx . . $ `<file>/Headers/SheenBidi/SBBidiType.h`/ |
| 22 | #include <SheenBidi/SBGeneralCategory.h>cxx . . $ `<file>/Headers/SheenBidi/SBGeneralCategory.h`/ |
| 23 | #include <SheenBidi/SBScript.h>cxx . . $ `<file>/Headers/SheenBidi/SBScript.h`/ |
| 24 | |
| 25 | SB_EXTERN_C_BEGINcxx . . $ `Headers/SheenBidi/SBBase.h:26:9`! |
| 26 | |
| 27 | /** |
| 28 | * A type to represent a Unicode code point. |
| 29 | */ |
| 30 | typedef SBUInt32cxx . . $ SBUInt32# SBCodepointcxx . . $ SBCodepoint#; |
| 31 | |
| 32 | /** |
| 33 | * A value representing an invalid Unicode code point. |
| 34 | */ |
| 35 | #define SBCodepointInvalidcxx . . $ `Headers/SheenBidi/SBCodepoint.h:35:9`! UINT32_MAXcxx . . $ `<external>/3415975807581488833/stdint.h:118:10`! |
| 36 | |
| 37 | /** |
| 38 | * A value representing a faulty Unicode code point. |
| 39 | * |
| 40 | * This value is used as a replacement for unrecognized code points during decoding. |
| 41 | */ |
| 42 | #define SBCodepointFaultycxx . . $ `Headers/SheenBidi/SBCodepoint.h:42:9`! 0xFFFD |
| 43 | |
| 44 | /** |
| 45 | * The maximum valid Unicode code point value. |
| 46 | * |
| 47 | * Unicode code points are valid in the range [0x0000, 0x10FFFF]. |
| 48 | */ |
| 49 | #define SBCodepointMaxcxx . . $ `Headers/SheenBidi/SBCodepoint.h:49:9`! 0x10FFFF |
| 50 | |
| 51 | /** |
| 52 | * Checks if a code point is a UTF-16 surrogate. |
| 53 | * |
| 54 | * Surrogate code points lie within the range [0xD800, 0xDFFF] and are not valid Unicode scalar |
| 55 | * values. |
| 56 | * |
| 57 | * @param c |
| 58 | * The code point to check. |
| 59 | * @return |
| 60 | * `true` if the code point is a surrogate, `false` otherwise. |
| 61 | */ |
| 62 | #define SBCodepointIsSurrogatecxx . . $ `Headers/SheenBidi/SBCodepoint.h:62:9`!(c) SBUInt32InRangecxx . . $ `Headers/SheenBidi/SBBase.h:130:9`!(c, 0xD800, 0xDFFF) |
| 63 | |
| 64 | /** |
| 65 | * Checks if a code point is a valid Unicode scalar value. |
| 66 | * |
| 67 | * A code point is considered valid if: |
| 68 | * - It is not a surrogate (i.e., not in the range 0xD800 to 0xDFFF) |
| 69 | * - It is less than or equal to SBCodepointMax (0x10FFFF). |
| 70 | * |
| 71 | * @param c |
| 72 | * The code point to check. |
| 73 | * @return |
| 74 | * `true` if the code point is valid, `false` otherwise. |
| 75 | */ |
| 76 | #define SBCodepointIsValidcxx . . $ `Headers/SheenBidi/SBCodepoint.h:76:9`!(c) (!SBCodepointIsSurrogatecxx . . $ `Headers/SheenBidi/SBCodepoint.h:62:9`!(c) && (c) <= SBCodepointMaxcxx . . $ `Headers/SheenBidi/SBCodepoint.h:49:9`!) |
| 77 | |
| 78 | /** |
| 79 | * Returns the bidirectional type of a Unicode code point. |
| 80 | * |
| 81 | * @param codepoint |
| 82 | * The code point whose bidirectional type is returned. |
| 83 | * @return |
| 84 | * The bidirectional type of the specified code point. |
| 85 | */ |
| 86 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBBidiTypecxx . . $ SBBidiType# SBCodepointGetBidiTypecxx . . $ SBCodepointGetBidiType(32407b39b2dfce37).(SBCodepointcxx . . $ SBCodepoint# codepoint); |
| 87 | |
| 88 | /** |
| 89 | * Returns the general category of a Unicode code point. |
| 90 | * |
| 91 | * @param codepoint |
| 92 | * The code point whose general category is returned. |
| 93 | * @return |
| 94 | * The general category of the specified code point. |
| 95 | */ |
| 96 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBGeneralCategorycxx . . $ SBGeneralCategory# SBCodepointGetGeneralCategorycxx . . $ SBCodepointGetGeneralCategory(32407b39b2dfce37).(SBCodepointcxx . . $ SBCodepoint# codepoint); |
| 97 | |
| 98 | /** |
| 99 | * Returns the mirrored code point for a given Unicode code point. |
| 100 | * |
| 101 | * @param codepoint |
| 102 | * The code point whose mirrored counterpart is returned. |
| 103 | * @return |
| 104 | * The mirrored code point if available, or 0 if no mirror exists. |
| 105 | */ |
| 106 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBCodepointcxx . . $ SBCodepoint# SBCodepointGetMirrorcxx . . $ SBCodepointGetMirror(2141b656ce2cc063).(SBCodepointcxx . . $ SBCodepoint# codepoint); |
| 107 | |
| 108 | /** |
| 109 | * Returns the script associated with a Unicode code point. |
| 110 | * |
| 111 | * @param codepoint |
| 112 | * The code point whose script is returned. |
| 113 | * @return |
| 114 | * The script of the specified code point. |
| 115 | */ |
| 116 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBScriptcxx . . $ SBScript# SBCodepointGetScriptcxx . . $ SBCodepointGetScript(32407b39b2dfce37).(SBCodepointcxx . . $ SBCodepoint# codepoint); |
| 117 | |
| 118 | /** |
| 119 | * Decodes the next Unicode code point from a UTF-8 encoded buffer. |
| 120 | * |
| 121 | * @param buffer |
| 122 | * The buffer containing UTF-8 encoded code units. |
| 123 | * @param length |
| 124 | * The length of the buffer. |
| 125 | * @param index |
| 126 | * The index at which decoding starts. On output, it is updated to the start of the next code |
| 127 | * point. |
| 128 | * @return |
| 129 | * The decoded code point, or `SBCodepointInvalid` if `index` is out of bounds. |
| 130 | */ |
| 131 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBCodepointcxx . . $ SBCodepoint# SBCodepointDecodeNextFromUTF8cxx . . $ SBCodepointDecodeNextFromUTF8(47ec3ebf21bc50ab).(const SBUInt8cxx . . $ SBUInt8# *buffer, SBUIntegercxx . . $ SBUInteger# length, |
| 132 | SBUIntegercxx . . $ SBUInteger# *index); |
| 133 | |
| 134 | /** |
| 135 | * Decodes the previous Unicode code point from a UTF-8 encoded buffer. |
| 136 | * |
| 137 | * @param buffer |
| 138 | * The buffer containing UTF-8 encoded code units. |
| 139 | * @param length |
| 140 | * The length of the buffer. |
| 141 | * @param index |
| 142 | * The index before which decoding occurs. On output, it is updated to the start of the |
| 143 | * decoded code point. |
| 144 | * @return |
| 145 | * The decoded code point, or `SBCodepointInvalid` if `index` is zero or out of bounds. |
| 146 | */ |
| 147 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBCodepointcxx . . $ SBCodepoint# SBCodepointDecodePreviousFromUTF8cxx . . $ SBCodepointDecodePreviousFromUTF8(47ec3ebf21bc50ab).(const SBUInt8cxx . . $ SBUInt8# *buffer, SBUIntegercxx . . $ SBUInteger# length, |
| 148 | SBUIntegercxx . . $ SBUInteger# *index); |
| 149 | |
| 150 | /** |
| 151 | * Decodes the next Unicode code point from a UTF-16 encoded buffer. |
| 152 | * |
| 153 | * @param buffer |
| 154 | * The buffer containing UTF-16 encoded code units. |
| 155 | * @param length |
| 156 | * The length of the buffer. |
| 157 | * @param index |
| 158 | * The index at which decoding starts. On output, it is updated to the start of the next code |
| 159 | * point. |
| 160 | * @return |
| 161 | * The decoded code point, or `SBCodepointInvalid` if `index` is out of bounds. |
| 162 | */ |
| 163 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBCodepointcxx . . $ SBCodepoint# SBCodepointDecodeNextFromUTF16cxx . . $ SBCodepointDecodeNextFromUTF16(21dbeba834daeca7).(const SBUInt16cxx . . $ SBUInt16# *buffer, SBUIntegercxx . . $ SBUInteger# length, |
| 164 | SBUIntegercxx . . $ SBUInteger# *index); |
| 165 | |
| 166 | /** |
| 167 | * Decodes the previous Unicode code point from a UTF-16 encoded buffer. |
| 168 | * |
| 169 | * @param buffer |
| 170 | * The buffer containing UTF-16 encoded code units. |
| 171 | * @param length |
| 172 | * The length of the buffer. |
| 173 | * @param index |
| 174 | * The index before which decoding occurs. On output, it is updated to the start of the |
| 175 | * decoded code point. |
| 176 | * @return |
| 177 | * The decoded code point, or `SBCodepointInvalid` if `index` is zero or out of bounds. |
| 178 | */ |
| 179 | SB_PUBLICcxx . . $ `Headers/SheenBidi/SBBase.h:39:9`! SBCodepointcxx . . $ SBCodepoint# SBCodepointDecodePreviousFromUTF16cxx . . $ SBCodepointDecodePreviousFromUTF16(21dbeba834daeca7).(const SBUInt16cxx . . $ SBUInt16# *buffer, SBUIntegercxx . . $ SBUInteger# length, |
| 180 | SBUIntegercxx . . $ SBUInteger# *index); |
| 181 | |
| 182 | SB_EXTERN_C_ENDcxx . . $ `Headers/SheenBidi/SBBase.h:27:9`! |
| 183 | |
| 184 | #endif |