Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
5aff007d | 3 | * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell |
460b9539 | 4 | * |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
460b9539 | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
460b9539 | 8 | * (at your option) any later version. |
e7eb3a27 RK |
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 | * | |
460b9539 | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 17 | */ |
132a5a4a | 18 | /** @file lib/charset.h @brief Character set conversion */ |
460b9539 | 19 | #ifndef CHARSET_H |
20 | #define CHARSET_H | |
21 | ||
05b75f8d RK |
22 | #include "log.h" |
23 | ||
13affe66 RK |
24 | struct dynstr; |
25 | ||
460b9539 | 26 | /* Character encoding conversion routines */ |
27 | ||
460b9539 | 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 | ||
0e4472a0 | 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 | */ | |
460b9539 | 58 | static inline char *nullcheck(char *s) { |
59 | if(!s) exitfn(1); /* assume an error already reported */ | |
60 | return s; | |
61 | } | |
62 | ||
61507e3c RK |
63 | const char *truncate_for_display(const char *s, long max); |
64 | ||
460b9539 | 65 | #endif /* CHARSET_H */ |
66 | ||
67 | /* | |
68 | Local Variables: | |
69 | c-basic-offset:2 | |
70 | comment-column:40 | |
71 | End: | |
72 | */ |