2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007-2009 Richard Kettlewell
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.
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.
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/>.
18 /** @file lib/charset.h @brief Character set conversion */
26 /* Character encoding conversion routines */
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. */
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 */
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. */
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
52 char *mb2utf8_f(char *mb);
53 char *utf82mb_f(char *utf8);
54 char *any2utf8_f(const char *from/*encoding*/,
56 char *any2mb_f(const char *from/*encoding or 0*/,
58 char *any2any_f(const char *from/*encoding or 0*/,
59 const char *to/*encoding to 0*/,
62 /** @brief Insist that @p s is not null
63 * @param s Pointer to check
66 * Terminates the process if @p s is a null pointer.
68 static inline char *nullcheck(char *s) {
69 if(!s) exitfn(1); /* assume an error already reported */
73 const char *truncate_for_display(const char *s, long max);
75 #endif /* CHARSET_H */