3 * This file is part of DisOrder.
4 * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
28 /* Character encoding conversion routines */
30 char *mb2utf8(const char *mb
);
31 char *utf82mb(const char *utf8
);
32 /* various conversions, between multibyte strings (mb) in
33 * whatever the current encoding is, and UTF-8 strings (utf8). On
34 * error, a null pointer is returned and @errno@ set. */
36 char *any2utf8(const char *from
/*encoding*/,
37 const char *any
/*string*/);
38 /* arbitrary conversions from any null-free byte-based encoding that
39 * iconv knows about to UTF-8 */
41 char *any2mb(const char *from
/*encoding or 0*/,
42 const char *any
/*string*/);
43 /* Arbitrary conversions from any null-free byte-based encoding that
44 * iconv knows about to a multibyte string. If FROM is 0 then ANY is
45 * returned unchanged. */
47 char *any2any(const char *from
/*encoding or 0*/,
48 const char *to
/*encoding to 0*/,
49 const char *any
/*string*/);
50 /* Arbitrary conversions between any null-free byte-based encodings
51 * that iconv knows. If FROM and TO are both 0 then ANY is returned
54 /** @brief Insist that @p s is not null
55 * @param s Pointer to check
58 * Terminates the process if @p s is a null pointer.
60 static inline char *nullcheck(char *s
) {
61 if(!s
) exitfn(1); /* assume an error already reported */
65 const char *truncate_for_display(const char *s
, long max
);
67 #endif /* CHARSET_H */