1/* $Id: unicode.h,v 1.1 2003/06/04 00:25:43 marka Exp $ */
2/*
3 * Copyright (c) 2000,2001 Japan Network Information Center.
4 * All rights reserved.
5 *
6 * By using this file, you agree to the terms and conditions set forth bellow.
7 *
8 * 			LICENSE TERMS AND CONDITIONS
9 *
10 * The following License Terms and Conditions apply, unless a different
11 * license is obtained from Japan Network Information Center ("JPNIC"),
12 * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
13 * Chiyoda-ku, Tokyo 101-0047, Japan.
14 *
15 * 1. Use, Modification and Redistribution (including distribution of any
16 *    modified or derived work) in source and/or binary forms is permitted
17 *    under this License Terms and Conditions.
18 *
19 * 2. Redistribution of source code must retain the copyright notices as they
20 *    appear in each source code file, this License Terms and Conditions.
21 *
22 * 3. Redistribution in binary form must reproduce the Copyright Notice,
23 *    this License Terms and Conditions, in the documentation and/or other
24 *    materials provided with the distribution.  For the purposes of binary
25 *    distribution the "Copyright Notice" refers to the following language:
26 *    "Copyright (c) 2000-2002 Japan Network Information Center.  All rights reserved."
27 *
28 * 4. The name of JPNIC may not be used to endorse or promote products
29 *    derived from this Software without specific prior written approval of
30 *    JPNIC.
31 *
32 * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
33 *    "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 *    LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
35 *    PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL JPNIC BE LIABLE
36 *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39 *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40 *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
41 *    OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
42 *    ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
43 */
44
45#ifndef IDN_UNICODE_H
46#define IDN_UNICODE_H 1
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/*
53 * Unicode attributes retriever.
54 *
55 * All the information this module provides is based on UnicodeData.txt,
56 * CompositionExclusions-1.txt and SpecialCasing.txt, all of which can be
57 * obtained from unicode.org.
58 *
59 * Unicode characters are represented as 'unsigned long'.
60 */
61
62#include <idn/result.h>
63
64/*
65 * A Handle for Unicode versions.
66 */
67typedef struct idn__unicode_ops *idn__unicode_version_t;
68
69/*
70 * Context information for case conversion.
71 */
72typedef enum {
73	idn__unicode_context_unknown,
74	idn__unicode_context_final,
75	idn__unicode_context_nonfinal
76} idn__unicode_context_t;
77
78/*
79 * Create a handle for a specific Unicode version.
80 * The version number (such as "3.0.1") is specified by 'version' parameter.
81 * If it is NULL, the latest version is used.
82 * The handle is stored in '*versionp', which is used various functions
83 * in this and unormalize modules.
84 *
85 * Returns:
86 *	idn_success		-- ok.
87 *	idn_notfound		-- specified version not found.
88 */
89extern idn_result_t
90idn__unicode_create(const char *version, idn__unicode_version_t *versionp);
91
92/*
93 * Close a handle which was created by 'idn__unicode_create'.
94 */
95extern void
96idn__unicode_destroy(idn__unicode_version_t version);
97
98/*
99 * Get canonical class.
100 *
101 * For characters out of unicode range (i.e. above 0xffff), 0 will
102 * be returned.
103 */
104extern int
105idn__unicode_canonicalclass(idn__unicode_version_t version, unsigned long c);
106
107/*
108 * Decompose a character.
109 *
110 * Decompose character given by 'c', and put the result into 'v',
111 * which can hold 'vlen' characters.  The number of decomposed characters
112 * will be stored in '*decomp_lenp'.
113 *
114 * If 'compat' is true, compatibility decomposition is performed.
115 * Otherwise canonical decomposition is done.
116 *
117 * Since decomposition is done recursively, no further decomposition
118 * will be needed.
119 *
120 * Returns:
121 *	idn_success		-- ok, decomposed.
122 *	idn_notfound		-- no decomposition possible.
123 *	idn_buffer_overflow	-- 'vlen' is too small.
124 */
125extern idn_result_t
126idn__unicode_decompose(idn__unicode_version_t version,
127		       int compat, unsigned long *v, size_t vlen,
128		       unsigned long c, int *decomp_lenp);
129
130/*
131 * Perform canonical composition.
132 *
133 * Do canonical composition to the character sequence 'c1' and 'c2', put the
134 * result into '*compp'.
135 *
136 * Since Unicode Nomalization Froms requires only canonical composition,
137 * compatibility composition is not supported.
138 *
139 * Returns:
140 *	idn_success		-- ok, composed.
141 *	idn_notfound		-- no composition possible.
142 */
143extern idn_result_t
144idn__unicode_compose(idn__unicode_version_t version,
145		     unsigned long c1, unsigned long c2, unsigned long *compp);
146
147/*
148 * Returns if there may be a canonical composition sequence which starts
149 * with the given character.
150 *
151 * Returns:
152 *	1			-- there may be a composition sequence
153 *				   (maybe not).
154 *	0			-- no, there is definitely no such sequences.
155 */
156extern int
157idn__unicode_iscompositecandidate(idn__unicode_version_t version,
158				  unsigned long c);
159
160#ifdef __cplusplus
161}
162#endif
163
164#endif /* IDN_UNICODE_H */
165