forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconv.h
57 lines (51 loc) · 1.37 KB
/
conv.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*-
* Copyright (c) 1992, 1993, 1994
* The Regents of the University of California. All rights reserved.
* Copyright (c) 1992, 1993, 1994, 1995, 1996
* Keith Bostic. All rights reserved.
* Copyright (c) 2011, 2012
* Zhihao Yuan. All rights reserved.
*
* See the LICENSE file for redistribution information.
*
* $Id: conv.h,v 2.32 2013/03/11 01:20:53 zy Exp $
*/
#ifdef USE_ICONV
#include <iconv.h>
#ifdef ICONV_TRADITIONAL
typedef char ** iconv_src_t;
#else
typedef char const ** iconv_src_t;
#endif
#else
typedef int iconv_t;
#endif
/*
* XXX
* We can not use MB_CUR_MAX here, since UTF-8 may report it as 6, but
* a sequence longer than 4 is deprecated by RFC 3629.
*/
#define KEY_NEEDSWIDE(sp, ch) \
(INTISWIDE(ch) && KEY_LEN(sp, ch) <= 4)
#define KEY_COL(sp, ch) \
(KEY_NEEDSWIDE(sp, ch) ? CHAR_WIDTH(sp, ch) : KEY_LEN(sp, ch))
enum { IC_FE_CHAR2INT, IC_FE_INT2CHAR, IC_IE_CHAR2INT, IC_IE_TO_UTF16 };
struct _conv_win {
union {
char *c;
CHAR_T *wc;
} bp1;
size_t blen1;
};
typedef int (*char2wchar_t)
(SCR *, const char *, ssize_t, struct _conv_win *, size_t *, CHAR_T **);
typedef int (*wchar2char_t)
(SCR *, const CHAR_T *, ssize_t, struct _conv_win *, size_t *, char **);
struct _conv {
char2wchar_t sys2int;
wchar2char_t int2sys;
char2wchar_t file2int;
wchar2char_t int2file;
char2wchar_t input2int;
iconv_t id[IC_IE_TO_UTF16 + 1];
};