xref: /netbsd-src/external/bsd/nvi/dist/common/conv.h (revision ae6aff383c30ab747b1aa3af361de7d98f07ffb8)
1 /*	$NetBSD: conv.h,v 1.4 2018/08/01 02:48:47 rin Exp $	*/
2 
3 /*
4  * We ensure that every wide char occupies at least one display width.
5  * See vs_line.c for more details.
6  */
7 #define WIDE_COL(sp, ch)						\
8 	(CHAR_WIDTH(sp, ch) > 0 ? CHAR_WIDTH(sp, ch) : 1)
9 
10 #define KEY_COL(sp, ch)							\
11 	(INTISWIDE(ch) ? (size_t)WIDE_COL(sp, ch) : KEY_LEN(sp, ch))
12 
13 struct _conv_win {
14     void    *bp1;
15     size_t   blen1;
16 };
17 
18 typedef int (*char2wchar_t)
19     (SCR *, const char *, ssize_t, struct _conv_win *, size_t *, const CHAR_T **);
20 typedef int (*wchar2char_t)
21     (SCR *, const CHAR_T *, ssize_t, struct _conv_win *, size_t *, const char **);
22 
23 struct _conv {
24 	char2wchar_t	sys2int;
25 	wchar2char_t	int2sys;
26 	char2wchar_t	file2int;
27 	wchar2char_t	int2file;
28 	char2wchar_t	input2int;
29 	wchar2char_t	int2disp;
30 };
31 void conv_init __P((SCR *, SCR *));
32 int conv_enc __P((SCR *, int, const char *));
33