diff options
Diffstat (limited to 'src/u8c/is.h.d')
-rw-r--r-- | src/u8c/is.h.d/isalnum.c | 32 | ||||
-rw-r--r-- | src/u8c/is.h.d/isalpha.c | 139 | ||||
-rw-r--r-- | src/u8c/is.h.d/iscntrl.c | 63 | ||||
-rw-r--r-- | src/u8c/is.h.d/isdigit.c | 43 | ||||
-rw-r--r-- | src/u8c/is.h.d/ispunct.c | 152 | ||||
-rw-r--r-- | src/u8c/is.h.d/isspace.c | 37 | ||||
-rw-r--r-- | src/u8c/is.h.d/isxdigit.c | 47 |
7 files changed, 513 insertions, 0 deletions
diff --git a/src/u8c/is.h.d/isalnum.c b/src/u8c/is.h.d/isalnum.c new file mode 100644 index 0000000..13834c3 --- /dev/null +++ b/src/u8c/is.h.d/isalnum.c @@ -0,0 +1,32 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_isalnum(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + uint_least8_t res = UINT8_C(0x0); + u8c_isalpha(&res,_chr); + if(res) { + *_res = res; + return false; + } + u8c_isdigit(&res,_chr); + *_res = res; + return false; +} diff --git a/src/u8c/is.h.d/isalpha.c b/src/u8c/is.h.d/isalpha.c new file mode 100644 index 0000000..d5952dc --- /dev/null +++ b/src/u8c/is.h.d/isalpha.c @@ -0,0 +1,139 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_isalpha(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'a': /* LATIN SMALL LETTER A */ + case U'b': /* LATIN SMALL LETTER B */ + case U'c': /* LATIN SMALL LETTER C */ + case U'd': /* LATIN SMALL LETTER D */ + case U'e': /* LATIN SMALL LETTER E */ + case U'f': /* LATIN SMALL LETTER F */ + case U'g': /* LATIN SMALL LETTER G */ + case U'h': /* LATIN SMALL LETTER H */ + case U'i': /* LATIN SMALL LETTER I */ + case U'j': /* LATIN SMALL LETTER J */ + case U'k': /* LATIN SMALL LETTER K */ + case U'l': /* LATIN SMALL LETTER L */ + case U'm': /* LATIN SMALL LETTER M */ + case U'n': /* LATIN SMALL LETTER N */ + case U'o': /* LATIN SMALL LETTER O */ + case U'p': /* LATIN SMALL LETTER P */ + case U'q': /* LATIN SMALL LETTER Q */ + case U'r': /* LATIN SMALL LETTER R */ + case U's': /* LATIN SMALL LETTER S */ + case U't': /* LATIN SMALL LETTER T */ + case U'u': /* LATIN SMALL LETTER U */ + case U'v': /* LATIN SMALL LETTER V */ + case U'w': /* LATIN SMALL LETTER W */ + case U'x': /* LATIN SMALL LETTER X */ + case U'y': /* LATIN SMALL LETTER Y */ + case U'z': /* LATIN SMALL LETTER Z */ + case U'\u00DF': /* LATIN SMALL LETTER SHARP S */ + case U'\u00E1': /* LATIN SMALL LETTER A WITH ACUTE */ + case U'\u00E4': /* LATIN SMALL LETTER A WITH DIAERESIS */ + case U'\u00E5': /* LATIN SMALL LETTER A WITH RING ABOVE */ + case U'\u00E6': /* LATIN SMALL LETTER AE */ + case U'\u00E7': /* LATIN SMALL LETTER C WITH CEDILLA */ + case U'\u00E9': /* LATIN SMALL LETTER E WITH ACUTE */ + case U'\u00ED': /* LATIN SMALL LETTER I WITH ACUTE */ + case U'\u00F0': /* LATIN SMALL LETTER ETH */ + case U'\u00F3': /* LATIN SMALL LETTER O WITH ACUTE */ + case U'\u00F6': /* LATIN SMALL LETTER O WITH DIAERESIS */ + case U'\u00F8': /* LATIN SMALL LETTER O WITH STROKE */ + case U'\u00FA': /* LATIN SMALL LETTER U WITH ACUTE */ + case U'\u00FC': /* U WITH TWO DOTS */ + case U'\u00FD': /* LATIN SMALL LETTER Y WITH ACUTE */ + case U'\u00FE': /* LATIN SMALL LETTER THORN */ + case U'\u0105': /* LATIN SMALL LETTER A WITH OGONEK */ + case U'\u0107': /* LATIN SMALL LETTER C WITH ACUTE */ + case U'\u010D': /* LATIN SMALL LETTER C WITH CARON */ + case U'\u010F': /* LATIN SMALL LETTER D WITH CARON */ + case U'\u0119': /* LATIN SMALL LETTER E WITH OGONEK */ + case U'\u011B': /* LATIN SMALL LETTER E WITH CARON */ + case U'\u011F': /* LATIN SMALL LETTER G WITH BREVE */ + case U'\u0131': /* LATIN SMALL LETTER DOTLESS I */ + case U'\u0133': /* LATIN SMALL LIGATURE LJ */ + case U'\u0138': /* LATIN SMALL LETTER KRA */ + case U'\u0142': /* LATIN SMALL LETTER L WITH STROKE */ + case U'\u0144': /* LATIN SMALL LETTER N WITH ACUTE */ + case U'\u0148': /* LATIN SMALL LETTER N WITH CARON */ + case U'\u014B': /* LATIN SMALL LETTER ENG */ + case U'\u0153': /* LATIN SMALL LIGATURE OE */ + case U'\u0159': /* LATIN SMALL LETTER R WITH CARON */ + case U'\u015B': /* LATIN SMALL LETTER S WITH ACUTE */ + case U'\u015F': /* LATIN SMALL LETTER S WITH CEDILLA */ + case U'\u0161': /* LATIN SMALL LETTER S WITH CARON */ + case U'\u0165': /* LATIN SMALL LETTER T WITH CARON */ + case U'\u016F': /* LATIN SMALL LETTER U WITH RING ABOVE */ + case U'\u017A': /* LATIN SMALL LETTER Z WITH ACUTE */ + case U'\u017C': /* LATIN SMALL LETTER Z WITH DOT ABOVE */ + case U'\u017E': /* LATIN SMALL LETTER Z WITH CARON */ + case U'\u01BF': /* LATIN LETTER WYNN */ + case U'\u01DD': /* LATIN SMALL LETTER TURNED E */ + case U'\u021D': /* LATIN SMALL LETTER YOGH */ + case U'\u0251': /* LATIN SMALL LETTER ALPHA */ + case U'\u0254': /* LATIN SMALL LETTER OPEN O */ + case U'\u0259': /* LATIN SMALL LETTER SCHWA */ + case U'\u025B': /* LATIN SMALL LETTER OPEN E */ + case U'\u0263': /* LATIN SMALL LETTER GAMMA */ + case U'\u0269': /* LATIN SMALL LETTER IOTA */ + case U'\u0283': /* LATIN SMALL LETTER ESH */ + case U'\u028A': /* LATIN SMALL LETTER UPSILON */ + case U'\u028B': /* LATIN SMALL LETTER V WITH HOOK */ + case U'\u0292': /* LATIN SMALL LETTER EZH */ + case U'\u0294': /* LATIN SMALL LETTER GLOTTAL STOP */ + case U'\u03B1': /* GREEK SMALL LETTER ALPHA */ + case U'\u03B2': /* GREEK SMALL LETTER BETA */ + case U'\u03B3': /* GREEK SMALL LETTER GAMMA */ + case U'\u03B4': /* GREEK SMALL LETTER DELTA */ + case U'\u03B5': /* GREEK SMALL LETTER EPSILON */ + case U'\u03B6': /* GREEK SMALL LETTER ZETA */ + case U'\u03B7': /* GREEK SMALL LETTER ETA */ + case U'\u03B8': /* GREEK SMALL LETTER THETA */ + case U'\u03B9': /* GREEK SMALL LETTER IOTA */ + case U'\u03BA': /* GREEK SMALL LETTER KAPPA */ + case U'\u03BB': /* GREEK SMALL LETTER LAMBDA */ + case U'\u03BC': /* GREEK SMALL LETTER MU */ + case U'\u03BD': /* GREEK SMALL LETTER NU */ + case U'\u03BE': /* GREEK SMALL LETTER XI */ + case U'\u03BF': /* GREEK SMALL LETTER OMICRON */ + case U'\u03C0': /* GREEK SMALL LETTER PI */ + case U'\u03C1': /* GREEK SMALL LETTER RHO */ + case U'\u03C2': /* GREEK SMALL LETTER FINAL SIGMA */ + case U'\u03C3': /* GREEK SMALL LETTER SIGMA */ + case U'\u03C4': /* GREEK SMALL LETTER TAU */ + case U'\u03C5': /* GREEK SMALL LETTER UPSILON */ + case U'\u03C6': /* GREEK SMALL LETTER PHI */ + case U'\u03C7': /* GREEK SMALL LETTER CHI */ + case U'\u03C8': /* GREEK SMALL LETTER PSI */ + case U'\u03C9': /* GREEK SMALL LETTER OMEGA */ + case U'\u1D79': /* LATIN SMALL LETTER INSULAR G */ + case U'\uA7B7': /* LATIN SMALL LETTER OMEGA */ + case U'\uFB00': /* LATIN SMALL LIGATURE FF */ + *_res = UINT8_C(0x1); + break; + } + return false; +} diff --git a/src/u8c/is.h.d/iscntrl.c b/src/u8c/is.h.d/iscntrl.c new file mode 100644 index 0000000..4dcf543 --- /dev/null +++ b/src/u8c/is.h.d/iscntrl.c @@ -0,0 +1,63 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_iscntrl(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'\x0': /* NULL */ + case U'\x1': /* START OF HEADING */ + case U'\x2': /* START OF TEXT */ + case U'\x3': /* END OF TEXT */ + case U'\x4': /* END OF TRANSMISSION */ + case U'\x5': /* ENQUIRY */ + case U'\x6': /* ACKNOWLEDGE */ + case U'\a': /* BELL */ + case U'\b': /* BACKSPACE */ + case U'\t': /* HORIZONTAL TABULATION */ + case U'\n': /* NEW LINE */ + case U'\v': /* VERTICAL TABULATION */ + case U'\f': /* FORM FEED */ + case U'\r': /* CARRIAGE RETURN */ + case U'\xE': /* SHIFT OUT */ + case U'\xF': /* SHIFT IN */ + case U'\x10': /* DATA LINK ESCAPE */ + case U'\x11': /* DEVICE CONTROL ONE */ + case U'\x12': /* DEVICE CONTROL TWO */ + case U'\x13': /* DEVICE CONTROL THREE */ + case U'\x14': /* DEVICE CONTROL FOUR */ + case U'\x15': /* NEGATIVE ACKNOWLEDGE */ + case U'\x16': /* SYNCHRONOUS IDLE */ + case U'\x17': /* END OF TRANSMISSION BLOCK */ + case U'\x18': /* CANCEL */ + case U'\x19': /* END OF MEDIUM */ + case U'\x1A': /* SUBSTITUTE */ + case U'\x1B': /* ESCAPE */ + case U'\x1C': /* FILE SEPERATOR */ + case U'\x1D': /* GROUP SEPERATOR */ + case U'\x1E': /* RECORD SEPERATOR */ + case U'\x1F': /* UNIT SEPERATOR */ + *_res = UINT8_C(0x1); + break; + } + return false; +} diff --git a/src/u8c/is.h.d/isdigit.c b/src/u8c/is.h.d/isdigit.c new file mode 100644 index 0000000..8b799d9 --- /dev/null +++ b/src/u8c/is.h.d/isdigit.c @@ -0,0 +1,43 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_isdigit(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'0': /* DIGIT ZERO */ + case U'1': /* DIGIT ONE */ + case U'2': /* DIGIT TWO */ + case U'3': /* DIGIT THREE */ + case U'4': /* DIGIT FOUR */ + case U'5': /* DIGIT FIVE */ + case U'6': /* DIGIT SIX */ + case U'7': /* DIGIT SEVEN */ + case U'8': /* DIGIT EIGHT */ + case U'9': /* DIGIT NINE */ + case U'\u218A': /* TURNED DIGIT TWO */ + case U'\u218B': /* TURNED DIGIT THREE */ + *_res = UINT8_C(0x1); + break; + } + return false; +} diff --git a/src/u8c/is.h.d/ispunct.c b/src/u8c/is.h.d/ispunct.c new file mode 100644 index 0000000..f6b041f --- /dev/null +++ b/src/u8c/is.h.d/ispunct.c @@ -0,0 +1,152 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_ispunct(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'!': /* EXCLAMATION MARK */ + case U'\"': /* QUOTATION MARK */ + case U'#': /* NUMBER SIGN */ + case U'\u0024': /* DOLLAR SIGN */ + case U'%': /* PERCENT SIGN */ + case U'&': /* AMPERSAND */ + case U'\'': /* APOSTROPHE */ + case U'(': /* LEFT PARANTHESIS */ + case U')': /* RIGHT PARANTHESIS */ + case U'*': /* ASTERISK */ + case U'+': /* PLUS SIGN */ + case U',': /* COMMA */ + case U'-': /* HYPHEN-MINUS */ + case U'.': /* FULL STOP */ + case U'/': /* SOLIDUS */ + case U':': /* COLON */ + case U';': /* SEMICOLON */ + case U'<': /* LESS-THAN SIGN */ + case U'=': /* EQUALS SIGN */ + case U'>': /* GREATER-THAN SIGN */ + case U'\?': /* QUESTION MARK */ + case U'\u0040': /* COMMERCIAL AT */ + case U'[': /* LEFT SQUARE BRACKET */ + case U'\\': /* REVERSE SOLIDUS */ + case U']': /* RIGHT SQUARE BRACKET */ + case U'^': /* CIRCUMFLEX ACCENT */ + case U'_': /* LOW LINE */ + case U'\u0060': /* GRAVE ACCENT */ + case U'{': /* LEFT CURLY BRACKET */ + case U'|': /* VERTICAL LINE */ + case U'}': /* RIGHT CURLY BRACKET */ + case U'~': /* TILDE */ + case U'\u00A1': /* INVERT EXCLAMATION MARK */ + case U'\u00A2': /* CENT SIGN */ + case U'\u00A3': /* POUND SIGN */ + case U'\u00A4': /* CURRENCY SIGN */ + case U'\u00A5': /* YEN SIGN */ + case U'\u00A7': /* SECTION SIGN */ + case U'\u00A8': /* DIAERESIS */ + case U'\u00A9': /* COPYRIGHT SIGN */ + case U'\u00AB': /* LEFT-POINTING DOUBLE ANGLE QUOTATION MARK */ + case U'\u00AE': /* REGISTERED SIGN */ + case U'\u00B0': /* DEGREE SIGN */ + case U'\u00B4': /* ACUTE ACCENT */ + case U'\u00B6': /* PILCROW SIGN */ + case U'\u00BB': /* RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK */ + case U'\u00B1': /* PLUS MINUS SIGN */ + case U'\u00BF': /* INVERT QUESTION MARK */ + case U'\u00D7': /* MULTIPLICATION SIGN */ + case U'\u00F7': /* DIVISION SIGN */ + case U'\u2010': /* HYPHEN */ + case U'\u2013': /* EN DASH */ + case U'\u2014': /* EM DASH */ + case U'\u2018': /* LEFT SINGLE QUOTATION MARK */ + case U'\u2019': /* RIGHT SINGLE QUOTATION MARK */ + case U'\u201C': /* LEFT DOUBLE QUOTATION MARK */ + case U'\u201D': /* RIGHT DOUBLE QUOTATION MARK */ + case U'\u2026': /* HORIZONTAL ELLIPSIS */ + case U'\u2030': /* PER MILLE SIGN */ + case U'\u20A3': /* FRENCH FRANC SIGN */ + case U'\u20A4': /* LIRA SIGN */ + case U'\u20A8': /* RUPEE SIGN */ + case U'\u20A9': /* WON SIGN */ + case U'\u20AC': /* EURO SIGN */ + case U'\u20B9': /* INDIAN RUPEE SIGN */ + case U'\u20BF': /* BITCOIN SIGN */ + case U'\u2103': /* DEGREE CELSIUS */ + case U'\u2107': /* EULER CONSTANT */ + case U'\u2109': /* DEGREE FAHRENHEIT */ + case U'\u210E': /* PLANCK CONSTANT */ + case U'\u2117': /* SOUND RECORDING COPYRIGHT */ + case U'\u2122': /* TRADE MARK SIGN */ + case U'\u2125': /* OUNCE SIGN */ + case U'\u2126': /* OHM SIGN */ + case U'\u212A': /* KELVIN SIGN */ + case U'\u214D': /* AKTIESELSKAB */ + case U'\u2205': /* EMPTY SET */ + case U'\u2212': /* MINUS SIGN */ + case U'\u221A': /* SQUARE ROOT */ + case U'\u221B': /* CUBE ROOT */ + case U'\u221C': /* FOURTH ROOT */ + case U'\u221E': /* INFINITY */ + case U'\u2228': /* LOGICAL OR */ + case U'\u2248': /* ALMOST EQUAL TO */ + case U'\u2260': /* NOT EQUAL TO */ + case U'\u2264': /* LESS-THAN OR EQUAL TO */ + case U'\u2265': /* GREATER-THAN OR EQUAL TO */ + case U'\u2609': /* SUN */ + case U'\u263F': /* MERCURY */ + case U'\u2640': /* FEMALE SIGN */ + case U'\u2641': /* EARTH */ + case U'\u2642': /* MALE SIGN */ + case U'\u2643': /* JUPITER */ + case U'\u2644': /* SATURN */ + case U'\u2645': /* URANUS */ + case U'\u2646': /* NEPTUNE */ + case U'\u2647': /* PLUTO */ + case U'\u26A2': /* DOUBLED FEMALE SIGN */ + case U'\u26A3': /* DOUBLED MALE SIGN */ + case U'\u26A4': /* INTERLOCKED FEMALE AND MALE SIGN */ + case U'\u26A5': /* MALE AND FEMALE SIGN */ + case U'\u26B3': /* CERES */ + case U'\u26B4': /* PALLAS */ + case U'\u26B5': /* JUNO */ + case U'\u26B6': /* VESTA */ + case U'\u26B7': /* CHIRON */ + case U'\u2BD8': /* PROSERPINA */ + case U'\u2BD9': /* ASTRAEA */ + case U'\u2BDA': /* HYGIEA */ + case U'\u2BDB': /* PHOLOS */ + case U'\u2BDC': /* NESSUS */ + case U'\u2E2E': /* INVERTED QUESTION MARK */ + case U'\u33D7': /* SQUARE PH */ + case U'\uFDFC': /* RIAL SIGN */ + case U'\U0001F10D': /* CIRCLED ZERO WITH SLASH */ + case U'\U0001F10E': /* CIRCLED ANTICKLOCKWISE ARROW */ + case U'\U0001F10F': /* CIRCLED DOLLAR SIGN WITH OVERLAID BACKSLASH */ + case U'\U0001F12F': /* COPYLEFT SYMBOL */ + case U'\U0001F16D': /* CIRCLED CC */ + case U'\U0001F16E': /* CIRCLED C WITH OVERLAID BACKSLASH */ + case U'\U0001F16F': /* CIRCLED HUMAN FIGURE */ + *_res = UINT8_C(0x1); + break; + } + return false; +} diff --git a/src/u8c/is.h.d/isspace.c b/src/u8c/is.h.d/isspace.c new file mode 100644 index 0000000..9473476 --- /dev/null +++ b/src/u8c/is.h.d/isspace.c @@ -0,0 +1,37 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_isspace(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'\t': /* HORIZONTAL TABULATION */ + case U'\n': /* NEW LINE */ + case U'\v': /* VERTICAL TABULATION */ + case U'\f': /* FORM FEED */ + case U'\r': /* CARRIAGE RETURN */ + case U' ': /* SPACE */ + *_res = UINT8_C(0x1); + break; + } + return false; +} diff --git a/src/u8c/is.h.d/isxdigit.c b/src/u8c/is.h.d/isxdigit.c new file mode 100644 index 0000000..4a59b0d --- /dev/null +++ b/src/u8c/is.h.d/isxdigit.c @@ -0,0 +1,47 @@ +/* + Copyright 2021 Gabriel Jensen + + This file is part of u8c. + + u8c is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + u8c is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License along with u8c. + + If not, see <https://www.gnu.org/licenses/>. +*/ +# include <assert.h> +# include <stdbool.h> +# include <stddef.h> +# include <stdint.h> +# include <u8c/is.h> +bool u8c_isxdigit(uint_least8_t * const _res,char32_t const _chr) { + assert(_res != NULL); + switch(_chr) { + default: + *_res = UINT8_C(0x0); + break; + case U'0': /* DIGIT ZERO */ + case U'1': /* DIGIT ONE */ + case U'2': /* DIGIT TWO */ + case U'3': /* DIGIT THREE */ + case U'4': /* DIGIT FOUR */ + case U'5': /* DIGIT FIVE */ + case U'6': /* DIGIT SIX */ + case U'7': /* DIGIT SEVEN */ + case U'8': /* DIGIT EIGHT */ + case U'9': /* DIGIT NINE */ + case U'A': /* LATIN CAPITAL LETTER A */ + case U'B': /* LATIN CAPITAL LETTER B */ + case U'C': /* LATIN CAPITAL LETTER C */ + case U'D': /* LATIN CAPITAL LETTER D */ + case U'E': /* LATIN CAPITAL LETTER E */ + case U'F': /* LATIN CAPITAL LETTER F */ + *_res = UINT8_C(0x1); + break; + } + return false; +} |