chiark / gitweb /
Fiddle with CSS+HTML in effort to get more consistent buttons
[disorder] / lib / charset.h
CommitLineData
05b75f8d 1
460b9539 2/*
3 * This file is part of DisOrder.
5aff007d 4 * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
460b9539 5 *
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.
10 *
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.
15 *
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
19 * USA
20 */
21#ifndef CHARSET_H
22#define CHARSET_H
23
05b75f8d
RK
24#include "log.h"
25
13affe66
RK
26struct dynstr;
27
460b9539 28/* Character encoding conversion routines */
29
460b9539 30char *mb2utf8(const char *mb);
31char *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. */
35
36char *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 */
40
41char *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. */
46
47char *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
52 * unchanged. */
53
0e4472a0 54/** @brief Insist that @p s is not null
55 * @param s Pointer to check
56 * @return @p s
57 *
58 * Terminates the process if @p s is a null pointer.
59 */
460b9539 60static inline char *nullcheck(char *s) {
61 if(!s) exitfn(1); /* assume an error already reported */
62 return s;
63}
64
61507e3c
RK
65const char *truncate_for_display(const char *s, long max);
66
460b9539 67#endif /* CHARSET_H */
68
69/*
70Local Variables:
71c-basic-offset:2
72comment-column:40
73End:
74*/