summaryrefslogtreecommitdiff
path: root/vendor/nunicode/include/libnu/casemap.h
blob: e851ab40ca5c882f190e59c73f5867ca236fb2c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#ifndef NU_TOUPPER_H
#define NU_TOUPPER_H

#include <stdint.h>

#include <libnu/config.h>
#include <libnu/defines.h>
#include <libnu/strings.h>
#include <libnu/udb.h>

#if defined (__cplusplus) || defined (c_plusplus)
extern "C" {
#endif

/**
 * @example folding.c
 * @example special_casing.c
 */

/** Synonim to nu_casemap_read. It is recommended to use
 * nu_casemap_read instead.
 */
#define NU_CASEMAP_DECODING_FUNCTION NU_UDB_DECODING_FUNCTION
/** Read (decoding) function for use with transformation results of
 * casemapping functions. E.g. nu_casemap_read(nu_tolower(0x0041));
 * will read first codepoint of 'A' transformed to lower case.
 */
#define nu_casemap_read (nu_udb_read)

/** Casemap codepoint
 *
 * @ingroup transformations
 */
typedef nu_transformation_t nu_casemapping_t;

#ifdef NU_WITH_TOUPPER

/** Return uppercase value of codepoint. Uncoditional casemapping.
 *
 * @ingroup transformations
 * @param codepoint unicode codepoint
 * @return uppercase codepoint or 0 if mapping doesn't exist
 */
NU_EXPORT
const char* nu_toupper(uint32_t codepoint);

/** Return uppercase value of codepoint. Context-sensitivity is not
 * implemented internally, returned result is equal to calling nu_toupper()
 * on corresponding codepoint.
 *
 * @ingroup transformations_internal
 * @param encoded pointer to encoded string
 * @param limit memory limit of encoded string or NU_UNLIMITED
 * @param read read (decoding) function
 * @param u (optional) codepoint which was (or wasn't) transformed
 * @param transform output value of codepoint transformed into uppercase or 0
 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with
 * nu_casemap_read
 * @param context not used
 * @return pointer to the next codepoint in string
 */
NU_EXPORT
const char* _nu_toupper(const char *encoded, const char *limit, nu_read_iterator_t read,
	uint32_t *u, const char **transform,
	void *context);

#endif /* NU_WITH_TOUPPER */

#ifdef NU_WITH_TOLOWER

/** Return lowercase value of codepoint. Unconditional casemapping.
 *
 * @ingroup transformations
 * @param codepoint unicode codepoint
 * @return lowercase codepoint or 0 if mapping doesn't exist
 */
NU_EXPORT
const char* nu_tolower(uint32_t codepoint);

/** Return lowercase value of codepoint. Will transform uppercase
 * Sigma ('Σ') into final sigma ('ς') if it occurs at string boundary or
 * followed by U+0000. Might require single read-ahead when
 * encountering Sigma.
 *
 * @ingroup transformations_internal
 * @param encoded pointer to encoded string
 * @param limit memory limit of encoded string or NU_UNLIMITED
 * @param read read (decoding) function
 * @param u (optional) codepoint which was (or wasn't) transformed
 * @param transform output value of codepoint transformed into lowercase or 0
 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with
 * nu_casemap_read
 * @param context not used
 * @return pointer to the next codepoint in string
 */
NU_EXPORT
const char* _nu_tolower(const char *encoded, const char *limit, nu_read_iterator_t read,
	uint32_t *u, const char **transform,
	void *context);

#endif /* NU_WITH_TOLOWER */

#ifdef NU_WITH_TOFOLD

/** Return value of codepoint with case differences eliminated
 *
 * @ingroup transformations
 * @param codepoint unicode codepoint
 * @return casefolded codepoint or 0 if mapping doesn't exist
 */
NU_EXPORT
const char* nu_tofold(uint32_t codepoint);

/** Return value of codepoint with case differences eliminated.
 * Context-sensitivity is not implemented internally, returned result is equal
 * to calling nu_tofold() on corresponding codepoint.
 *
 * @ingroup transformations_internal
 * @param encoded pointer to encoded string
 * @param limit memory limit of encoded string or NU_UNLIMITED
 * @param read read (decoding) function
 * @param u (optional) codepoint which was (or wasn't) transformed
 * @param transform output value of casefolded codepoint or 0
 * if mapping doesn't exist. Can't be NULL, supposed to be decoded with
 * nu_casemap_read
 * @param context not used
 * @return pointer to the next codepoint in string
 */
NU_EXPORT
const char* _nu_tofold(const char *encoded, const char *limit, nu_read_iterator_t read,
	uint32_t *u, const char **transform,
	void *context);

#endif /* NU_WITH_TOFOLD */

#if defined (__cplusplus) || defined (c_plusplus)
}
#endif

#endif /* NU_TOUPPER_H */