| 1 | #cxx . . $ `<file>/melder/melder_kar.h`/ifndef _melder_kar_h_ |
| 2 | #define _melder_kar_h_cxx . . $ `melder/melder_kar.h:2:9`! |
| 3 | /* melder_kar.h |
| 4 | * |
| 5 | * Copyright (C) 1992-2020,2024 Paul Boersma |
| 6 | * |
| 7 | * This code is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or (at |
| 10 | * your option) any later version. |
| 11 | * |
| 12 | * This code is distributed in the hope that it will be useful, but |
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 15 | * See the GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this work. If not, see <http://www.gnu.org/licenses/>. |
| 19 | */ |
| 20 | |
| 21 | #define kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! 127 |
| 22 | #define kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! 0x2FA1D |
| 23 | #define kUCD_UNASSIGNEDcxx . . $ `melder/melder_kar.h:23:9`! 0 |
| 24 | |
| 25 | enumcxx . . $ $anonymous_type_2c11447c81a52d64_0# { |
| 26 | mUCD_UPPERCASE_LETTERcxx . . $ mUCD_UPPERCASE_LETTER. = (1 << 0), |
| 27 | mUCD_LOWERCASE_LETTERcxx . . $ mUCD_LOWERCASE_LETTER. = (1 << 1), |
| 28 | mUCD_TITLECASE_LETTERcxx . . $ mUCD_TITLECASE_LETTER. = (1 << 2), |
| 29 | mUCD_CASED_LETTERcxx . . $ mUCD_CASED_LETTER. = (mUCD_UPPERCASE_LETTERcxx . . $ mUCD_UPPERCASE_LETTER. | mUCD_LOWERCASE_LETTERcxx . . $ mUCD_LOWERCASE_LETTER. | mUCD_TITLECASE_LETTERcxx . . $ mUCD_TITLECASE_LETTER.), |
| 30 | mUCD_MODIFIER_LETTERcxx . . $ mUCD_MODIFIER_LETTER. = (1 << 3), |
| 31 | mUCD_OTHER_LETTERcxx . . $ mUCD_OTHER_LETTER. = (1 << 4), |
| 32 | mUCD_LETTERcxx . . $ mUCD_LETTER. = (mUCD_CASED_LETTERcxx . . $ mUCD_CASED_LETTER. | mUCD_MODIFIER_LETTERcxx . . $ mUCD_MODIFIER_LETTER. | mUCD_OTHER_LETTERcxx . . $ mUCD_OTHER_LETTER.), |
| 33 | |
| 34 | mUCD_NONSPACING_MARKcxx . . $ mUCD_NONSPACING_MARK. = (1 << 5), |
| 35 | mUCD_SPACING_MARKcxx . . $ mUCD_SPACING_MARK. = (1 << 6), |
| 36 | mUCD_ENCLOSING_MARKcxx . . $ mUCD_ENCLOSING_MARK. = (1 << 7), |
| 37 | mUCD_MARKcxx . . $ mUCD_MARK. = (mUCD_NONSPACING_MARKcxx . . $ mUCD_NONSPACING_MARK. | mUCD_SPACING_MARKcxx . . $ mUCD_SPACING_MARK. | mUCD_ENCLOSING_MARKcxx . . $ mUCD_ENCLOSING_MARK.), |
| 38 | |
| 39 | mUCD_DECIMAL_NUMBERcxx . . $ mUCD_DECIMAL_NUMBER. = (1 << 8), |
| 40 | mUCD_LETTER_NUMBERcxx . . $ mUCD_LETTER_NUMBER. = (1 << 9), |
| 41 | mUCD_OTHER_NUMBERcxx . . $ mUCD_OTHER_NUMBER. = (1 << 10), |
| 42 | mUCD_NUMBERcxx . . $ mUCD_NUMBER. = (mUCD_DECIMAL_NUMBERcxx . . $ mUCD_DECIMAL_NUMBER. | mUCD_LETTER_NUMBERcxx . . $ mUCD_LETTER_NUMBER. | mUCD_OTHER_NUMBERcxx . . $ mUCD_OTHER_NUMBER.), |
| 43 | |
| 44 | mUCD_CONNECTOR_PUNCTUATIONcxx . . $ mUCD_CONNECTOR_PUNCTUATION. = (1 << 11), |
| 45 | mUCD_DASH_PUNCTUATIONcxx . . $ mUCD_DASH_PUNCTUATION. = (1 << 12), |
| 46 | mUCD_OPEN_PUNCTUATIONcxx . . $ mUCD_OPEN_PUNCTUATION. = (1 << 13), |
| 47 | mUCD_CLOSE_PUNCTUATIONcxx . . $ mUCD_CLOSE_PUNCTUATION. = (1 << 14), |
| 48 | mUCD_INITIAL_PUNCTUATIONcxx . . $ mUCD_INITIAL_PUNCTUATION. = (1 << 15), |
| 49 | mUCD_FINAL_PUNCTUATIONcxx . . $ mUCD_FINAL_PUNCTUATION. = (1 << 16), |
| 50 | mUCD_OTHER_PUNCTUATIONcxx . . $ mUCD_OTHER_PUNCTUATION. = (1 << 17), |
| 51 | mUCD_PUNCTUATIONcxx . . $ mUCD_PUNCTUATION. = (mUCD_CONNECTOR_PUNCTUATIONcxx . . $ mUCD_CONNECTOR_PUNCTUATION. | mUCD_DASH_PUNCTUATIONcxx . . $ mUCD_DASH_PUNCTUATION. | mUCD_OPEN_PUNCTUATIONcxx . . $ mUCD_OPEN_PUNCTUATION. | mUCD_CLOSE_PUNCTUATIONcxx . . $ mUCD_CLOSE_PUNCTUATION. | mUCD_INITIAL_PUNCTUATIONcxx . . $ mUCD_INITIAL_PUNCTUATION. | mUCD_FINAL_PUNCTUATIONcxx . . $ mUCD_FINAL_PUNCTUATION. | mUCD_OTHER_PUNCTUATIONcxx . . $ mUCD_OTHER_PUNCTUATION.), |
| 52 | |
| 53 | mUCD_MATH_SYMBOLcxx . . $ mUCD_MATH_SYMBOL. = (1 << 18), |
| 54 | mUCD_CURRENCY_SYMBOLcxx . . $ mUCD_CURRENCY_SYMBOL. = (1 << 19), |
| 55 | mUCD_MODIFIER_SYMBOLcxx . . $ mUCD_MODIFIER_SYMBOL. = (1 << 20), |
| 56 | mUCD_OTHER_SYMBOLcxx . . $ mUCD_OTHER_SYMBOL. = (1 << 21), |
| 57 | mUCD_SYMBOLcxx . . $ mUCD_SYMBOL. = (mUCD_MATH_SYMBOLcxx . . $ mUCD_MATH_SYMBOL. | mUCD_CURRENCY_SYMBOLcxx . . $ mUCD_CURRENCY_SYMBOL. | mUCD_MODIFIER_SYMBOLcxx . . $ mUCD_MODIFIER_SYMBOL. | mUCD_OTHER_SYMBOLcxx . . $ mUCD_OTHER_SYMBOL.), |
| 58 | |
| 59 | mUCD_BREAKING_SPACEcxx . . $ mUCD_BREAKING_SPACE. = (1 << 22), |
| 60 | mUCD_NON_BREAKING_SPACEcxx . . $ mUCD_NON_BREAKING_SPACE. = (1 << 23), // note: this keeps *lines* together; it still separates *words*, despite interpretations elsewhere |
| 61 | mUCD_SPACE_SEPARATORcxx . . $ mUCD_SPACE_SEPARATOR. = (mUCD_BREAKING_SPACEcxx . . $ mUCD_BREAKING_SPACE. | mUCD_NON_BREAKING_SPACEcxx . . $ mUCD_NON_BREAKING_SPACE.), |
| 62 | mUCD_LINE_SEPARATORcxx . . $ mUCD_LINE_SEPARATOR. = (1 << 24), |
| 63 | mUCD_PARAGRAPH_SEPARATORcxx . . $ mUCD_PARAGRAPH_SEPARATOR. = (1 << 25), |
| 64 | mUCD_NEWLINEcxx . . $ mUCD_NEWLINE. = (mUCD_LINE_SEPARATORcxx . . $ mUCD_LINE_SEPARATOR. | mUCD_PARAGRAPH_SEPARATORcxx . . $ mUCD_PARAGRAPH_SEPARATOR.), |
| 65 | mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR. = (mUCD_SPACE_SEPARATORcxx . . $ mUCD_SPACE_SEPARATOR. | mUCD_NEWLINEcxx . . $ mUCD_NEWLINE.), |
| 66 | |
| 67 | mUCD_CONTROLcxx . . $ mUCD_CONTROL. = (1 << 26), |
| 68 | mUCD_FORMATcxx . . $ mUCD_FORMAT. = (1 << 27), |
| 69 | mUCD_PRIVATE_USEcxx . . $ mUCD_PRIVATE_USE. = (1 << 28), |
| 70 | |
| 71 | mUCD_WORD_CHARACTERcxx . . $ mUCD_WORD_CHARACTER. = (1 << 29), |
| 72 | mUCD_NULLcxx . . $ mUCD_NULL. = (1 << 30), |
| 73 | |
| 74 | mUCD_ALPHANUMERICcxx . . $ mUCD_ALPHANUMERIC. = (mUCD_LETTERcxx . . $ mUCD_LETTER. | mUCD_NUMBERcxx . . $ mUCD_NUMBER.), |
| 75 | mUCD_END_OF_INKcxx . . $ mUCD_END_OF_INK. = (mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR. | mUCD_NULLcxx . . $ mUCD_NULL.), |
| 76 | mUCD_END_OF_LINEcxx . . $ mUCD_END_OF_LINE. = (mUCD_NEWLINEcxx . . $ mUCD_NEWLINE. | mUCD_NULLcxx . . $ mUCD_NULL.), |
| 77 | }; |
| 78 | |
| 79 | struct UCD_CodePointInfocxx . . $ UCD_CodePointInfo# { |
| 80 | uint32cxx . . $ uint32# featurescxx . . $ UCD_CodePointInfo#features.; |
| 81 | char32cxx . . $ char32# upperCasecxx . . $ UCD_CodePointInfo#upperCase., lowerCasecxx . . $ UCD_CodePointInfo#lowerCase., titleCasecxx . . $ UCD_CodePointInfo#titleCase.; |
| 82 | conststring32cxx . . $ conststring32# decomposedcxx . . $ UCD_CodePointInfo#decomposed.; |
| 83 | char firstcxx . . $ UCD_CodePointInfo#first., secondcxx . . $ UCD_CodePointInfo#second.; |
| 84 | }; |
| 85 | extern UCD_CodePointInfocxx . . $ UCD_CodePointInfo# theUnicodeDatabasecxx . . $ theUnicodeDatabase. [1+kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`!]; |
| 86 | |
| 87 | /* |
| 88 | Praat is an internationalized program, which means it has to work in the same way |
| 89 | wherever on earth it is used. This means that Praat has to be blind to localized settings, |
| 90 | such as what counts as a space and what combinations of characters |
| 91 | count as pairs of lower case and upper case. |
| 92 | |
| 93 | To be able to use Praat all over the world, we therefore define one single |
| 94 | "international locale", which is simply based on the Unicode features of each code point. |
| 95 | */ |
| 96 | |
| 97 | /* |
| 98 | Internationalize std::isblank (): |
| 99 | */ |
| 100 | inline bool Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 101 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_SPACE_SEPARATORcxx . . $ mUCD_SPACE_SEPARATOR.) != 0; |
| 102 | } |
| 103 | inline void Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(28edbb7a9cd1ae27). (char32cxx . . $ char32# **p_text) { |
| 104 | while (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (**p_text)) |
| 105 | (*p_text) ++; |
| 106 | } |
| 107 | inline void Melder_skipHorizontalSpacecxx . . $ Melder_skipHorizontalSpace(1babf4dbe7380927). (const char32cxx . . $ char32# **p_text) { |
| 108 | while (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (**p_text)) |
| 109 | (*p_text) ++; |
| 110 | } |
| 111 | inline char32cxx . . $ char32# * Melder_findEndOfHorizontalSpacecxx . . $ Melder_findEndOfHorizontalSpace(732f4804158f7631). (char32cxx . . $ char32# *p) { |
| 112 | while (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*p)) |
| 113 | p ++; |
| 114 | return p; |
| 115 | } |
| 116 | inline const char32cxx . . $ char32# * Melder_findEndOfHorizontalSpacecxx . . $ Melder_findEndOfHorizontalSpace(5553299aa8c4fee9). (const char32cxx . . $ char32# *p) { |
| 117 | while (Melder_isHorizontalSpacecxx . . $ Melder_isHorizontalSpace(b8d0204ce8416907). (*p)) |
| 118 | p ++; |
| 119 | return p; |
| 120 | } |
| 121 | |
| 122 | inline bool Melder_isAsciiHorizontalSpacecxx . . $ Melder_isAsciiHorizontalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 123 | return kar == U'\t' || kar == U' '; |
| 124 | } |
| 125 | |
| 126 | inline bool Melder_isVerticalSpacecxx . . $ Melder_isVerticalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 127 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_NEWLINEcxx . . $ mUCD_NEWLINE.) != 0; |
| 128 | } |
| 129 | inline bool Melder_isAsciiVerticalSpacecxx . . $ Melder_isAsciiVerticalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 130 | return kar >= 10 && kar <= 13; // \n, \v, \f, \r |
| 131 | } |
| 132 | |
| 133 | /* |
| 134 | Internationalize std::isspace (): |
| 135 | */ |
| 136 | inline bool Melder_isHorizontalOrVerticalSpacecxx . . $ Melder_isHorizontalOrVerticalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 137 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR.) != 0; |
| 138 | } |
| 139 | inline bool Melder_isAsciiHorizontalOrVerticalSpacecxx . . $ Melder_isAsciiHorizontalOrVerticalSpace(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 140 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR.) != 0; |
| 141 | } |
| 142 | inline void Melder_skipHorizontalOrVerticalSpacecxx . . $ Melder_skipHorizontalOrVerticalSpace(28edbb7a9cd1ae27). (char32cxx . . $ char32# **p_text) { |
| 143 | while (Melder_isHorizontalOrVerticalSpacecxx . . $ Melder_isHorizontalOrVerticalSpace(b8d0204ce8416907). (**p_text)) |
| 144 | (*p_text) ++; |
| 145 | } |
| 146 | inline void Melder_skipHorizontalOrVerticalSpacecxx . . $ Melder_skipHorizontalOrVerticalSpace(1babf4dbe7380927). (const char32cxx . . $ char32# **p_text) { |
| 147 | while (Melder_isHorizontalOrVerticalSpacecxx . . $ Melder_isHorizontalOrVerticalSpace(b8d0204ce8416907). (**p_text)) |
| 148 | (*p_text) ++; |
| 149 | } |
| 150 | |
| 151 | inline bool Melder_isEndOfInkcxx . . $ Melder_isEndOfInk(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 152 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_END_OF_INKcxx . . $ mUCD_END_OF_INK.) != 0; |
| 153 | } |
| 154 | inline bool Melder_isEndOfLinecxx . . $ Melder_isEndOfLine(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 155 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_END_OF_LINEcxx . . $ mUCD_END_OF_LINE.) != 0; |
| 156 | } |
| 157 | inline bool Melder_isEndOfTextcxx . . $ Melder_isEndOfText(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 158 | return kar == U'\0'; |
| 159 | } |
| 160 | inline bool Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 161 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_END_OF_INKcxx . . $ mUCD_END_OF_INK.) == 0; |
| 162 | } |
| 163 | inline bool Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 164 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_END_OF_LINEcxx . . $ mUCD_END_OF_LINE.) == 0; |
| 165 | } |
| 166 | inline void Melder_skipToEndOfLinecxx . . $ Melder_skipToEndOfLine(28edbb7a9cd1ae27). (char32cxx . . $ char32# **p_text) { |
| 167 | while (Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (**p_text)) |
| 168 | (*p_text) ++; |
| 169 | } |
| 170 | inline char32cxx . . $ char32# * Melder_findEndOfInkcxx . . $ Melder_findEndOfInk(732f4804158f7631). (char32cxx . . $ char32# *p) { |
| 171 | while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*p)) |
| 172 | p ++; |
| 173 | return p; |
| 174 | } |
| 175 | inline const char32cxx . . $ char32# * Melder_findEndOfInkcxx . . $ Melder_findEndOfInk(5553299aa8c4fee9). (const char32cxx . . $ char32# *p) { |
| 176 | while (Melder_staysWithinInkcxx . . $ Melder_staysWithinInk(b8d0204ce8416907). (*p)) |
| 177 | p ++; |
| 178 | return p; |
| 179 | } |
| 180 | inline char32cxx . . $ char32# * Melder_findEndOfLinecxx . . $ Melder_findEndOfLine(732f4804158f7631). (char32cxx . . $ char32# *p) { |
| 181 | while (Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) |
| 182 | p ++; |
| 183 | return p; |
| 184 | } |
| 185 | inline const char32cxx . . $ char32# * Melder_findEndOfLinecxx . . $ Melder_findEndOfLine(5553299aa8c4fee9). (const char32cxx . . $ char32# *p) { |
| 186 | while (Melder_staysWithinLinecxx . . $ Melder_staysWithinLine(b8d0204ce8416907). (*p)) |
| 187 | p ++; |
| 188 | return p; |
| 189 | } |
| 190 | |
| 191 | /* |
| 192 | Internationalize std::isalpha (): |
| 193 | */ |
| 194 | inline bool Melder_isLettercxx . . $ Melder_isLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 195 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_LETTERcxx . . $ mUCD_LETTER.) != 0; |
| 196 | } |
| 197 | inline bool Melder_isAsciiLettercxx . . $ Melder_isAsciiLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 198 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_LETTERcxx . . $ mUCD_LETTER.) != 0; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | Internationalize std::isupper (): |
| 203 | */ |
| 204 | inline bool Melder_isUpperCaseLettercxx . . $ Melder_isUpperCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 205 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_UPPERCASE_LETTERcxx . . $ mUCD_UPPERCASE_LETTER.) != 0; |
| 206 | } |
| 207 | inline bool Melder_isAsciiUpperCaseLettercxx . . $ Melder_isAsciiUpperCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 208 | return kar >= U'A' && kar <= U'Z'; |
| 209 | } |
| 210 | |
| 211 | /* |
| 212 | Internationalize std::islower (): |
| 213 | */ |
| 214 | inline bool Melder_isLowerCaseLettercxx . . $ Melder_isLowerCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 215 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_LOWERCASE_LETTERcxx . . $ mUCD_LOWERCASE_LETTER.) != 0; |
| 216 | } |
| 217 | inline bool Melder_isAsciiLowerCaseLettercxx . . $ Melder_isAsciiLowerCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 218 | return kar >= U'a' && kar <= U'z'; |
| 219 | } |
| 220 | |
| 221 | inline bool Melder_isTitleCaseLettercxx . . $ Melder_isTitleCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 222 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_TITLECASE_LETTERcxx . . $ mUCD_TITLECASE_LETTER.) != 0; |
| 223 | } |
| 224 | inline bool Melder_isAsciiTitleCaseLettercxx . . $ Melder_isAsciiTitleCaseLetter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 225 | return kar >= U'A' && kar <= U'Z'; |
| 226 | } |
| 227 | |
| 228 | /* |
| 229 | Internationalize std::isdigit (): |
| 230 | */ |
| 231 | inline bool Melder_isDecimalNumbercxx . . $ Melder_isDecimalNumber(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 232 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_DECIMAL_NUMBERcxx . . $ mUCD_DECIMAL_NUMBER.) != 0; |
| 233 | } |
| 234 | inline bool Melder_isAsciiDecimalNumbercxx . . $ Melder_isAsciiDecimalNumber(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 235 | return kar >= U'0' && kar <= U'9'; |
| 236 | } |
| 237 | |
| 238 | /* |
| 239 | We cannot really internationalize std::isxdigit (): |
| 240 | */ |
| 241 | inline bool Melder_isHexadecimalDigitcxx . . $ Melder_isHexadecimalDigit(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 242 | return (kar >= U'0' && kar <= U'9') || (kar >= U'A' && kar <= U'Z') || (kar >= U'a' && kar <= U'z'); |
| 243 | } |
| 244 | |
| 245 | /* |
| 246 | Internationalize std::isalnum (): |
| 247 | */ |
| 248 | inline bool Melder_isAlphanumericcxx . . $ Melder_isAlphanumeric(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 249 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_ALPHANUMERICcxx . . $ mUCD_ALPHANUMERIC.) != 0; |
| 250 | } |
| 251 | inline bool Melder_isAsciiAlphanumericcxx . . $ Melder_isAsciiAlphanumeric(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 252 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_ALPHANUMERICcxx . . $ mUCD_ALPHANUMERIC.) != 0; |
| 253 | } |
| 254 | |
| 255 | inline bool Melder_isWordCharactercxx . . $ Melder_isWordCharacter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 256 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_WORD_CHARACTERcxx . . $ mUCD_WORD_CHARACTER.) != 0; |
| 257 | } |
| 258 | inline bool Melder_isAsciiWordCharactercxx . . $ Melder_isAsciiWordCharacter(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 259 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_WORD_CHARACTERcxx . . $ mUCD_WORD_CHARACTER.) != 0; |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | The standard library further contains std::ispunct (), std::iscntrl (), std::isprint (), std::isgraph (). |
| 264 | These have very little use nowadays, so only for completeness do we include versions of them here, |
| 265 | which are correct at least for ASCII arguments. |
| 266 | Of these four functions, Melder_hasInk () is not yet correct for all Unicode points, |
| 267 | as approximately one half of the mUCD_FORMAT points are inkless as well. |
| 268 | */ |
| 269 | inline bool Melder_isPunctuationOrSymbolcxx . . $ Melder_isPunctuationOrSymbol(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 270 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & (mUCD_PUNCTUATIONcxx . . $ mUCD_PUNCTUATION. | mUCD_SYMBOLcxx . . $ mUCD_SYMBOL.)) != 0; |
| 271 | } |
| 272 | inline bool Melder_isAsciiPunctuationOrSymbolcxx . . $ Melder_isAsciiPunctuationOrSymbol(b8d0204ce8416907). (char32cxx . . $ char32# kar) { // same as std::ispunct() with default C locale |
| 273 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & (mUCD_PUNCTUATIONcxx . . $ mUCD_PUNCTUATION. | mUCD_SYMBOLcxx . . $ mUCD_SYMBOL.)) != 0; |
| 274 | } |
| 275 | inline bool Melder_isControlcxx . . $ Melder_isControl(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 276 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_CONTROLcxx . . $ mUCD_CONTROL.) != 0; |
| 277 | } |
| 278 | inline bool Melder_isAsciiControlcxx . . $ Melder_isAsciiControl(b8d0204ce8416907). (char32cxx . . $ char32# kar) { // same as std::iscntrl() with default C locale |
| 279 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_CONTROLcxx . . $ mUCD_CONTROL.) != 0; |
| 280 | } |
| 281 | inline bool Melder_isPrintablecxx . . $ Melder_isPrintable(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 282 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_CONTROLcxx . . $ mUCD_CONTROL.) == 0; |
| 283 | } |
| 284 | inline bool Melder_isAsciiPrintablecxx . . $ Melder_isAsciiPrintable(b8d0204ce8416907). (char32cxx . . $ char32# kar) { // same as std::isprint() with default C locale |
| 285 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & mUCD_CONTROLcxx . . $ mUCD_CONTROL.) == 0; |
| 286 | } |
| 287 | inline bool Melder_hasInkcxx . . $ Melder_hasInk(b8d0204ce8416907). (char32cxx . . $ char32# kar) { |
| 288 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & (mUCD_CONTROLcxx . . $ mUCD_CONTROL. | mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR.)) == 0; |
| 289 | } |
| 290 | inline bool Melder_hasAsciiInkcxx . . $ Melder_hasAsciiInk(b8d0204ce8416907). (char32cxx . . $ char32# kar) { // same as std::isgraph() with default C locale |
| 291 | return kar <= kUCD_TOP_OF_ASCIIcxx . . $ `melder/melder_kar.h:21:9`! && (theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. featurescxx . . $ UCD_CodePointInfo#features. & (mUCD_CONTROLcxx . . $ mUCD_CONTROL. | mUCD_SEPARATORcxx . . $ mUCD_SEPARATOR.)) == 0; |
| 292 | } |
| 293 | |
| 294 | /* |
| 295 | Internationalize std::toupper () and std::tolower (): |
| 296 | */ |
| 297 | inline char32cxx . . $ char32# Melder_toUpperCasecxx . . $ Melder_toUpperCase(cd1afca5b9692c51). (char32cxx . . $ char32# kar) { |
| 298 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! ? theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. upperCasecxx . . $ UCD_CodePointInfo#upperCase. : kar; |
| 299 | } |
| 300 | inline char32cxx . . $ char32# Melder_toLowerCasecxx . . $ Melder_toLowerCase(cd1afca5b9692c51). (char32cxx . . $ char32# kar) { |
| 301 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! ? theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. lowerCasecxx . . $ UCD_CodePointInfo#lowerCase. : kar; |
| 302 | } |
| 303 | inline char32cxx . . $ char32# Melder_toTitleCasecxx . . $ Melder_toTitleCase(cd1afca5b9692c51). (char32cxx . . $ char32# kar) { |
| 304 | return kar <= kUCD_TOP_OF_LISTcxx . . $ `melder/melder_kar.h:22:9`! ? theUnicodeDatabasecxx . . $ theUnicodeDatabase. [kar]. titleCasecxx . . $ UCD_CodePointInfo#titleCase. : kar; |
| 305 | } |
| 306 | |
| 307 | /* |
| 308 | Search functions instantiating strspn() but much faster (CHECK). |
| 309 | */ |
| 310 | inline const char32cxx . . $ char32# * Melder_findInkcxx . . $ Melder_findInk(efea2b2856d283a0). (conststring32cxx . . $ conststring32# str) noexcept { |
| 311 | if (! str) |
| 312 | return nullptr; |
| 313 | const char32cxx . . $ char32# *p = & str [0]; |
| 314 | for (; ! Melder_hasInkcxx . . $ Melder_hasInk(b8d0204ce8416907). (*p); p ++) { |
| 315 | if (*p == U'\0') |
| 316 | return nullptr; // not found |
| 317 | } |
| 318 | return p; |
| 319 | } |
| 320 | inline const char32cxx . . $ char32# * Melder_findHorizontalOrVerticalSpacecxx . . $ Melder_findHorizontalOrVerticalSpace(efea2b2856d283a0). (conststring32cxx . . $ conststring32# str) noexcept { |
| 321 | if (! str) |
| 322 | return nullptr; |
| 323 | const char32cxx . . $ char32# *p = & str [0]; |
| 324 | for (; ! Melder_isHorizontalOrVerticalSpacecxx . . $ Melder_isHorizontalOrVerticalSpace(b8d0204ce8416907). (*p); p ++) |
| 325 | if (*p == U'\0') |
| 326 | return nullptr; // not found |
| 327 | return p; |
| 328 | } |
| 329 | |
| 330 | #include "../kar/wctype_portable.h"cxx . . $ `<file>/kar/wctype_portable.h`/ |
| 331 | |
| 332 | /* End of file melder_kar.h */ |
| 333 | #endif |