1 /* Header file for UTF-8 functions
2 Copyright (C) 2001, 2002 Peter Verthez
4 The UTF8 tools library is free software; you can redistribute it
5 and/or modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The Gedcom parser library is distributed in the hope that it will be
10 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the Gedcom parser library; if not, write to the
16 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
30 #include <sys/types.h>
34 typedef struct conv_buffer *conv_buffer_t;
35 typedef struct convert *convert_t;
37 /* Returns -1 if the string is not a valid UTF-8 string, returns its
38 string length otherwise */
39 int utf8_strlen(const char* input);
41 /* Returns 1 if string is valid UTF-8 string, 0 otherwise */
42 int is_utf8_string(const char* input);
44 /* Returns respectively a pointer to the next or the nth UTF-8 character.
45 The value n = 0 is the first character of the input, i.e.
46 next_utf8_char(input) is the same as nth_utf8_char(input, 1) */
47 char* next_utf8_char(char* input);
48 char* nth_utf8_char(char* input, int n);
50 /* Functions for creating and freeing conversion buffers yourself */
51 conv_buffer_t create_conv_buffer(int size);
52 void free_conv_buffer(conv_buffer_t buf);
54 /* General conversion interface (is bidirectional) */
55 /* Pass 0 for external_outbuf unless you want to control the
56 output buffer yourself */
57 convert_t initialize_utf8_conversion(const char* charset, int external_outbuf);
58 int conversion_set_unknown(convert_t conv, const char* unknown);
59 int conversion_set_output_buffer(convert_t conv, conv_buffer_t buf);
60 void cleanup_utf8_conversion(convert_t conv);
61 char* convert_from_utf8(convert_t conv, const char* input, int* conv_fails,
63 char* convert_to_utf8(convert_t conv, const char* input, size_t input_len);
64 char* convert_to_utf8_incremental(convert_t conv,
65 const char* input, size_t input_len);
67 /* Specific locale conversion interface (initializes a convert_t structure
69 void convert_set_unknown(const char* unknown);
70 char* convert_utf8_to_locale(const char* input, int *conv_fails);
71 char* convert_locale_to_utf8(const char* input);
77 #endif /* __UTF8TOOLS_H */