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 int one_ucs42utf8(uint32_t c
, struct dynstr
*d
);
29 uint32_t *utf82ucs4(const char *mb
);
30 char *ucs42utf8(const uint32_t *u
);
31 char *mb2utf8(const char *mb
);
32 char *utf82mb(const char *utf8
);
33 /* various conversions, between multibyte strings (mb) in
34 * whatever the current encoding is, and UTF-8 strings (utf8). On
35 * error, a null pointer is returned and @errno@ set. */
37 char *any2utf8(const char *from
/*encoding*/,
38 const char *any
/*string*/);
39 /* arbitrary conversions from any null-free byte-based encoding that
40 * iconv knows about to UTF-8 */
42 char *any2mb(const char *from
/*encoding or 0*/,
43 const char *any
/*string*/);
44 /* Arbitrary conversions from any null-free byte-based encoding that
45 * iconv knows about to a multibyte string. If FROM is 0 then ANY is
46 * returned unchanged. */
48 char *any2any(const char *from
/*encoding or 0*/,
49 const char *to
/*encoding to 0*/,
50 const char *any
/*string*/);
51 /* Arbitrary conversions between any null-free byte-based encodings
52 * that iconv knows. If FROM and TO are both 0 then ANY is returned
55 /** @brief Insist that @p s is not null
56 * @param s Pointer to check
59 * Terminates the process if @p s is a null pointer.
61 static inline char *nullcheck(char *s
) {
62 if(!s
) exitfn(1); /* assume an error already reported */
66 int ucs4cmp(const uint32_t *a
, const uint32_t *b
);
69 const char *truncate_for_display(const char *s
, long max
);
71 #endif /* CHARSET_H */