Doxygen file headers for most files
[disorder] / lib / charset.h
1 /*
2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 /** @file lib/charset.h @brief Character set conversion */
19 #ifndef CHARSET_H
20 #define CHARSET_H
21
22 #include "log.h"
23
24 struct dynstr;
25
26 /* Character encoding conversion routines */
27
28 char *mb2utf8(const char *mb);
29 char *utf82mb(const char *utf8);
30 /* various conversions, between multibyte strings (mb) in
31 * whatever the current encoding is, and UTF-8 strings (utf8). On
32 * error, a null pointer is returned and @errno@ set. */
33
34 char *any2utf8(const char *from/*encoding*/,
35 const char *any/*string*/);
36 /* arbitrary conversions from any null-free byte-based encoding that
37 * iconv knows about to UTF-8 */
38
39 char *any2mb(const char *from/*encoding or 0*/,
40 const char *any/*string*/);
41 /* Arbitrary conversions from any null-free byte-based encoding that
42 * iconv knows about to a multibyte string. If FROM is 0 then ANY is
43 * returned unchanged. */
44
45 char *any2any(const char *from/*encoding or 0*/,
46 const char *to/*encoding to 0*/,
47 const char *any/*string*/);
48 /* Arbitrary conversions between any null-free byte-based encodings
49 * that iconv knows. If FROM and TO are both 0 then ANY is returned
50 * unchanged. */
51
52 /** @brief Insist that @p s is not null
53 * @param s Pointer to check
54 * @return @p s
55 *
56 * Terminates the process if @p s is a null pointer.
57 */
58 static inline char *nullcheck(char *s) {
59 if(!s) exitfn(1); /* assume an error already reported */
60 return s;
61 }
62
63 const char *truncate_for_display(const char *s, long max);
64
65 #endif /* CHARSET_H */
66
67 /*
68 Local Variables:
69 c-basic-offset:2
70 comment-column:40
71 End:
72 */