ekg2  GIT master
nc-strings.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 #ifndef __EKG_STRINGS_H
4 #define __EKG_STRINGS_H
5 
6 /*
7  * (C) Copyright 2003-2006 Maciej Pietrzak <maciej@hell.org.pl>
8  * Jakub Zawadzki <darkjames@darkjames.ath.cx>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License Version 2 as
12  * published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
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., 675 Mass Ave, Cambridge, MA 02139, USA.
22  */
23 
24 #include "ekg2-config.h"
25 #include "ecurses.h"
26 
27 #if USE_UNICODE
28 
29 #include <wchar.h> /* wchar_t stuff */
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 extern int config_use_unicode; /* not everyone want to include stuff.h */
36 
37 #define CHAR_T wchar_t
38 #define TEXT(x) (wchar_t *) L##x
39 #define CHAR(x) (wchar_t) L##x
40 #define STRING_FORMAT "%ls"
41 #define CHAR_FORMAT "%lc"
42 
43 size_t xwcslen(const CHAR_T *str);
44 size_t xmbslen(const char *str);
45 CHAR_T *xwcscpy(CHAR_T *dst, CHAR_T *src);
46 CHAR_T *xwcsdup(CHAR_T *str);
47 CHAR_T *xwcscat(CHAR_T *dst, const CHAR_T *src);
48 int xwcscmp(const CHAR_T *s1, const CHAR_T *s2);
49 CHAR_T *xwcschr(const CHAR_T *s, CHAR_T c);
50 char *wcs_to_normal(const CHAR_T *str);
51 CHAR_T *normal_to_wcs(const char *str);
52 CHAR_T **wcs_array_make(const CHAR_T *string, const CHAR_T *sep, int max, int trim, int quotes);
53 CHAR_T *wcs_array_join(CHAR_T **array, const CHAR_T *sep);
54 size_t xwcslcpy(CHAR_T *dst, const CHAR_T *src, size_t size);
55 
56 #define free_utf(x) xfree(x)
57 
58 #else /* USE_UNICODE */
59 
60 #include <glib.h>
61 #include <ekg/xmalloc.h>
62 
63 #ifdef __cplusplus
64 extern "C" {
65 #endif
66 
67 #define CHAR_T unsigned char
68 #define TEXT(x) x
69 #define CHAR(x) x
70 #define STRING_FORMAT "%s"
71 #define CHAR_FORMAT "%c"
72 
73 #define xwcslen(str) xstrlen((char *) str)
74 #define xmbslen(str) xstrlen(str)
75 #define xwcscpy(dst, str) xstrcpy((char *) dst, (char *) str)
76 #define xwcsdup(str) (CHAR_T *) xstrdup((char *) str)
77 #define xwcscat(dst, src) xstrcat((char *) dst, (char *) src)
78 #define xwcscmp(s1, s2) xstrcmp((char *) s1, (char *) s2)
79 #define xwcschr(s, c) xstrchr((char *) s, c)
80 #define wcs_to_normal(x) (char *) x
81 #define wcs_array_make(str, sep, max, trim, quotes) (CHAR_T **) array_make((char *) str, sep, max, trim, quotes)
82 #define wcs_array_join(arr, sep) (CHAR_T *) g_strjoinv(sep, (char **) arr)
83 #define xwcslcpy(dst, src, size) g_strlcpy((char *) dst, (char *) src, size)
84 #define free_utf(x)
85 
86 #endif /* USE_UNICODE */
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif /* __EKG_STRINGS_H */
wchar_t * xwcsdup(wchar_t *str)
Definition: nc-strings.c:50
size_t xwcslcpy(wchar_t *dst, const wchar_t *src, size_t size)
Definition: nc-strings.c:110
wchar_t * xwcscpy(wchar_t *dst, wchar_t *src)
Definition: nc-strings.c:46
wchar_t * xwcscat(wchar_t *dst, const wchar_t *src)
Definition: nc-strings.c:55
size_t xwcslen(const wchar_t *str)
Definition: nc-strings.c:38
wchar_t * wcs_array_join(wchar_t **array, const wchar_t *sep)
Definition: nc-strings.c:126
wchar_t * xwcschr(const wchar_t *s, wchar_t c)
Definition: nc-strings.c:63
char * wcs_to_normal(const wchar_t *str)
Definition: nc-strings.c:67
int xwcscmp(const wchar_t *s1, const wchar_t *s2)
Definition: nc-strings.c:59
#define CHAR_T
Definition: nc-strings.h:37
int config_use_unicode
size_t xmbslen(const char *str)
Definition: nc-strings.c:42
#define s
wchar_t ** wcs_array_make(const wchar_t *string, const wchar_t *sep, int max, int trim, int quotes)
Definition: nc-strings.c:90
wchar_t * normal_to_wcs(const char *str)
Definition: nc-strings.c:80