2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005 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 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * 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, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25 /* Character encoding conversion routines */
27 char *mb2utf8(const char *mb);
28 char *utf82mb(const char *utf8);
29 /* various conversions, between multibyte strings (mb) in
30 * whatever the current encoding is, and UTF-8 strings (utf8). On
31 * error, a null pointer is returned and @errno@ set. */
33 char *any2utf8(const char *from/*encoding*/,
34 const char *any/*string*/);
35 /* arbitrary conversions from any null-free byte-based encoding that
36 * iconv knows about to UTF-8 */
38 char *any2mb(const char *from/*encoding or 0*/,
39 const char *any/*string*/);
40 /* Arbitrary conversions from any null-free byte-based encoding that
41 * iconv knows about to a multibyte string. If FROM is 0 then ANY is
42 * returned unchanged. */
44 char *any2any(const char *from/*encoding or 0*/,
45 const char *to/*encoding to 0*/,
46 const char *any/*string*/);
47 /* Arbitrary conversions between any null-free byte-based encodings
48 * that iconv knows. If FROM and TO are both 0 then ANY is returned
51 /** @brief Insist that @p s is not null
52 * @param s Pointer to check
55 * Terminates the process if @p s is a null pointer.
57 static inline char *nullcheck(char *s) {
58 if(!s) exitfn(1); /* assume an error already reported */
62 const char *truncate_for_display(const char *s, long max);
64 #endif /* CHARSET_H */