Updated italian translation
[midnight-commander.git] / src / ecs.h
blob571d93e07f0de722d31f5d3ac6cd6771f8ced63c
1 /*
2 Basic support for extended character sets.
4 Written by:
5 Roland Illig <roland.illig@gmx.de>, 2005.
7 This file is part of the Midnight Commander.
9 The Midnight Commander is free software; you can redistribute it
10 and/or modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version.
14 The Midnight Commander is distributed in the hope that it will be
15 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
16 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 MA 02110-1301, USA.
25 #ifndef MC_ECS_H
26 #define MC_ECS_H
29 * This header provides string processing functions for extended
30 * character sets (ECS), as well as for the traditional one-to-one
31 * byte-to-character encoding.
34 /* Use the macros ECS_CHAR and ECS_STR to bring character and string
35 * literals to the correct form required by the C compiler. */
36 #ifdef EXTCHARSET_ENABLED
37 # include <stdlib.h>
38 typedef wchar_t ecs_char;
39 # define ECS_CHAR(c) (L##c)
40 # define ECS_STR(s) (L##s)
41 #else
42 typedef char ecs_char;
43 # define ECS_CHAR(c) (c)
44 # define ECS_STR(s) (s)
45 #endif
48 * String conversion functions between the wide character encoding and
49 * the multibyte encoding. The returned strings should be freed using
50 * g_free after use. The return value is TRUE if the string is valid
51 * and has been converted, FALSE otherwise.
54 extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *);
55 extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *);
58 * Replacements for the ISO C90 <ctype.h> functions.
61 extern gboolean ecs_isalnum(ecs_char);
62 extern gboolean ecs_isalpha(ecs_char);
63 extern gboolean ecs_iscntrl(ecs_char);
64 extern gboolean ecs_isdigit(ecs_char);
65 extern gboolean ecs_isgraph(ecs_char);
66 extern gboolean ecs_islower(ecs_char);
67 extern gboolean ecs_isprint(ecs_char);
68 extern gboolean ecs_ispunct(ecs_char);
69 extern gboolean ecs_isspace(ecs_char);
70 extern gboolean ecs_isupper(ecs_char);
71 extern gboolean ecs_isxdigit(ecs_char);
74 * Replacements for the ISO C90 <string.h> functions.
77 /* left out: ecs_strcpy */
78 /* left out: ecs_strncpy */
79 /* left out: ecs_strcat */
80 /* left out: ecs_strncat */
81 extern int ecs_strcmp(const ecs_char *, const ecs_char *);
82 /* left out: ecs_strcoll */
83 /* left out: ecs_strncmp */
84 /* left out: ecs_strxfrm */
85 extern ecs_char *ecs_strchr(const ecs_char *, ecs_char);
86 extern size_t ecs_strcspn(const ecs_char *, const ecs_char *);
87 /* left out: ecs_strpbrk */
88 extern ecs_char *ecs_strrchr(const ecs_char *, ecs_char);
89 extern size_t ecs_strspn(const ecs_char *, const ecs_char *);
90 extern ecs_char *ecs_strstr(const ecs_char *, const ecs_char *);
91 /* left out: ecs_strtok */
92 extern size_t ecs_strlen(const ecs_char *);
95 * Other string functions.
98 /* allocates a copy of the string. Never returns NULL. */
99 extern ecs_char *ecs_xstrdup(const ecs_char *);
101 extern size_t ecs_strlcpy(ecs_char *, const ecs_char *, size_t);
102 extern size_t ecs_strlcat(ecs_char *, const ecs_char *, size_t);
104 /* calculates the bounds of the box that the string would occupy when
105 * displayed on screen. Returns TRUE if all characters in the string are
106 * either '\n' or printable, according to the current locale. If the
107 * return value is FALSE, ''width'' and ''height'' are not modified. */
108 extern gboolean ecs_strbox(const ecs_char *, size_t *ret_width,
109 size_t *ret_height);
111 #endif