misc/mc.lib: changes in hotkeys definitions.
[midnight-commander.git] / src / ecs.h
blob66e3e6601665a89b3b86e68e9664804996a67304
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 /** \file ecs.h
26 * \brief Header: basic support for extended character sets
29 #ifndef MC_ECS_H
30 #define MC_ECS_H
33 * This header provides string processing functions for extended
34 * character sets (ECS), as well as for the traditional one-to-one
35 * byte-to-character encoding.
38 /* Use the macros ECS_CHAR and ECS_STR to bring character and string
39 * literals to the correct form required by the C compiler. */
40 #ifdef EXTCHARSET_ENABLED
41 # include <stdlib.h>
42 typedef wchar_t ecs_char;
43 # define ECS_CHAR(c) (L##c)
44 # define ECS_STR(s) (L##s)
45 #else
46 typedef char ecs_char;
47 # define ECS_CHAR(c) (c)
48 # define ECS_STR(s) (s)
49 #endif
52 * String conversion functions between the wide character encoding and
53 * the multibyte encoding. The returned strings should be freed using
54 * g_free after use. The return value is TRUE if the string is valid
55 * and has been converted, FALSE otherwise.
58 extern gboolean ecs_mbstr_to_str(ecs_char **ret_str, const char *);
59 extern gboolean ecs_str_to_mbstr(char **ret_str, const ecs_char *);
62 * Replacements for the ISO C90 <ctype.h> functions.
65 extern gboolean ecs_isalnum(ecs_char);
66 extern gboolean ecs_isalpha(ecs_char);
67 extern gboolean ecs_iscntrl(ecs_char);
68 extern gboolean ecs_isdigit(ecs_char);
69 extern gboolean ecs_isgraph(ecs_char);
70 extern gboolean ecs_islower(ecs_char);
71 extern gboolean ecs_isprint(ecs_char);
72 extern gboolean ecs_ispunct(ecs_char);
73 extern gboolean ecs_isspace(ecs_char);
74 extern gboolean ecs_isupper(ecs_char);
75 extern gboolean ecs_isxdigit(ecs_char);
78 * Replacements for the ISO C90 <string.h> functions.
81 /* left out: ecs_strcpy */
82 /* left out: ecs_strncpy */
83 /* left out: ecs_strcat */
84 /* left out: ecs_strncat */
85 extern int ecs_strcmp(const ecs_char *, const ecs_char *);
86 /* left out: ecs_strcoll */
87 /* left out: ecs_strncmp */
88 /* left out: ecs_strxfrm */
89 extern ecs_char *ecs_strchr(const ecs_char *, ecs_char);
90 extern size_t ecs_strcspn(const ecs_char *, const ecs_char *);
91 /* left out: ecs_strpbrk */
92 extern ecs_char *ecs_strrchr(const ecs_char *, ecs_char);
93 extern size_t ecs_strspn(const ecs_char *, const ecs_char *);
94 extern ecs_char *ecs_strstr(const ecs_char *, const ecs_char *);
95 /* left out: ecs_strtok */
96 extern size_t ecs_strlen(const ecs_char *);
99 * Other string functions.
102 /* allocates a copy of the string. Never returns NULL. */
103 extern ecs_char *ecs_xstrdup(const ecs_char *);
105 extern size_t ecs_strlcpy(ecs_char *, const ecs_char *, size_t);
106 extern size_t ecs_strlcat(ecs_char *, const ecs_char *, size_t);
108 /* calculates the bounds of the box that the string would occupy when
109 * displayed on screen. Returns TRUE if all characters in the string are
110 * either '\n' or printable, according to the current locale. If the
111 * return value is FALSE, ''width'' and ''height'' are not modified. */
112 extern gboolean ecs_strbox(const ecs_char *, size_t *ret_width,
113 size_t *ret_height);
115 #endif