1 #ifndef NU_TOUPPER_H 2 #define NU_TOUPPER_H 3 4 #include <stdint.h> 5 6 #include <libnu/config.h> 7 #include <libnu/defines.h> 8 #include <libnu/strings.h> 9 #include <libnu/udb.h> 10 11 #if defined (__cplusplus) || defined (c_plusplus) 12 extern "C" { 13 #endif 14 15 /** 16 * @example folding.c 17 * @example special_casing.c 18 */ 19 20 /** Synonim to nu_casemap_read. It is recommended to use 21 * nu_casemap_read instead. 22 */ 23 #define NU_CASEMAP_DECODING_FUNCTION NU_UDB_DECODING_FUNCTION 24 /** Read (decoding) function for use with transformation results of 25 * casemapping functions. E.g. nu_casemap_read(nu_tolower(0x0041)); 26 * will read first codepoint of 'A' transformed to lower case. 27 */ 28 #define nu_casemap_read (nu_udb_read) 29 30 /** Casemap codepoint 31 * 32 * @ingroup transformations 33 */ 34 typedef nu_transformation_t nu_casemapping_t; 35 36 #ifdef NU_WITH_TOUPPER 37 38 /** Return uppercase value of codepoint. Uncoditional casemapping. 39 * 40 * @ingroup transformations 41 * @param codepoint unicode codepoint 42 * @return uppercase codepoint or 0 if mapping doesn't exist 43 */ 44 NU_EXPORT 45 const char* nu_toupper(uint32_t codepoint); 46 47 /** Return uppercase value of codepoint. Context-sensitivity is not 48 * implemented internally, returned result is equal to calling nu_toupper() 49 * on corresponding codepoint. 50 * 51 * @ingroup transformations_internal 52 * @param encoded pointer to encoded string 53 * @param limit memory limit of encoded string or NU_UNLIMITED 54 * @param read read (decoding) function 55 * @param u (optional) codepoint which was (or wasn't) transformed 56 * @param transform output value of codepoint transformed into uppercase or 0 57 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with 58 * nu_casemap_read 59 * @param context not used 60 * @return pointer to the next codepoint in string 61 */ 62 NU_EXPORT 63 const char* _nu_toupper(const char *encoded, const char *limit, nu_read_iterator_t read, 64 uint32_t *u, const char **transform, 65 void *context); 66 67 #endif /* NU_WITH_TOUPPER */ 68 69 #ifdef NU_WITH_TOLOWER 70 71 /** Return lowercase value of codepoint. Unconditional casemapping. 72 * 73 * @ingroup transformations 74 * @param codepoint unicode codepoint 75 * @return lowercase codepoint or 0 if mapping doesn't exist 76 */ 77 NU_EXPORT 78 const char* nu_tolower(uint32_t codepoint); 79 80 /** Return lowercase value of codepoint. Will transform uppercase 81 * Sigma ('Σ') into final sigma ('ς') if it occurs at string boundary or 82 * followed by U+0000. Might require single read-ahead when 83 * encountering Sigma. 84 * 85 * @ingroup transformations_internal 86 * @param encoded pointer to encoded string 87 * @param limit memory limit of encoded string or NU_UNLIMITED 88 * @param read read (decoding) function 89 * @param u (optional) codepoint which was (or wasn't) transformed 90 * @param transform output value of codepoint transformed into lowercase or 0 91 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with 92 * nu_casemap_read 93 * @param context not used 94 * @return pointer to the next codepoint in string 95 */ 96 NU_EXPORT 97 const char* _nu_tolower(const char *encoded, const char *limit, nu_read_iterator_t read, 98 uint32_t *u, const char **transform, 99 void *context); 100 101 #endif /* NU_WITH_TOLOWER */ 102 103 #ifdef NU_WITH_TOFOLD 104 105 /** Return value of codepoint with case differences eliminated 106 * 107 * @ingroup transformations 108 * @param codepoint unicode codepoint 109 * @return casefolded codepoint or 0 if mapping doesn't exist 110 */ 111 NU_EXPORT 112 const char* nu_tofold(uint32_t codepoint); 113 114 /** Return value of codepoint with case differences eliminated. 115 * Context-sensitivity is not implemented internally, returned result is equal 116 * to calling nu_tofold() on corresponding codepoint. 117 * 118 * @ingroup transformations_internal 119 * @param encoded pointer to encoded string 120 * @param limit memory limit of encoded string or NU_UNLIMITED 121 * @param read read (decoding) function 122 * @param u (optional) codepoint which was (or wasn't) transformed 123 * @param transform output value of casefolded codepoint or 0 124 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with 125 * nu_casemap_read 126 * @param context not used 127 * @return pointer to the next codepoint in string 128 */ 129 NU_EXPORT 130 const char* _nu_tofold(const char *encoded, const char *limit, nu_read_iterator_t read, 131 uint32_t *u, const char **transform, 132 void *context); 133 134 #endif /* NU_WITH_TOFOLD */ 135 136 #if defined (__cplusplus) || defined (c_plusplus) 137 } 138 #endif 139 140 #endif /* NU_TOUPPER_H */ 141