1 /*-----------------------------------------------------------------------
2 $Id: utf8.h 1025 2008-04-08 22:59:38Z hubert@u.washington.edu $
3 -----------------------------------------------------------------------*/
6 * ========================================================================
7 * Copyright 2013-2022 Eduardo Chappa
8 * Copyright 2006-2008 University of Washington
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
19 #ifndef PITH_CHARCONV_UTF8_INCLUDED
20 #define PITH_CHARCONV_UTF8_INCLUDED
24 #include "../filttype.h"
27 /* flags for convert_to_utf8 */
29 #define CU8_NOINFER 0x01 /* Not ok to infer charset */
33 * The data in vl and dl is UCS-4 characters.
34 * They are arrays of size vlen and dlen of unsigned longs.
37 int row
, col
; /* where display starts */
38 UCS
*vl
; /* virtual line, the actual data string */
39 int vlen
; /* size of vl array */
40 int vused
; /* elements of vl in use */
41 int vbase
; /* index into array, first virtual char on display */
42 UCS
*dl
; /* visible part of virtual line on display */
44 int dlen
; /* size of dl array */
45 int dwid
; /* screenwidth avail for dl */
46 void (*movecursor
)(int, int);
47 void (*writechar
)(UCS
);
54 void init_utf8_display(int, void *);
56 int wtomb(char *, UCS
);
57 UCS
mbtow(void *, unsigned char **, unsigned long *);
58 void set_locale_charmap(char *);
59 char *convert_to_utf8(char *, char *, int);
60 char *convert_to_locale(char *);
61 int utf8_to_locale(int c
, CBUF_S
*cb
, unsigned char obuf
[], size_t obuf_size
);
62 unsigned ucs4_str_width(UCS
*);
63 unsigned ucs4_str_width_a_to_b(UCS
*, int, int);
64 unsigned ucs4_str_width_ptr_to_ptr(UCS
*, UCS
*);
65 UCS
*ucs4_particular_width(UCS
*, int);
66 UCS
*utf8_to_ucs4_cpystr(char *);
67 char *ucs4_to_utf8_cpystr(UCS
*);
68 char *ucs4_to_utf8_cpystr_n(UCS
*, int);
69 char *ucs4_to_utf8_n_cpystr(UCS
*, int);
71 LPTSTR
utf8_to_lptstr(LPSTR
);
72 LPSTR
lptstr_to_utf8(LPTSTR
);
73 LPTSTR
ucs4_to_lptstr(UCS
*);
74 UCS
*lptstr_to_ucs4(LPTSTR
);
76 int utf8_to_ucs4_oneatatime(int, CBUF_S
*, UCS
*, int *);
77 size_t ucs4_strlen(UCS
*s
);
78 int ucs4_strcmp(UCS
*s1
, UCS
*s2
);
79 UCS
*ucs4_cpystr(UCS
*s
);
80 UCS
*ucs4_strncpy(UCS
*ucs4dst
, UCS
*ucs4src
, size_t n
);
81 UCS
*ucs4_strncat(UCS
*ucs4dst
, UCS
*ucs4src
, size_t n
);
82 UCS
*ucs4_strchr(UCS
*s
, UCS c
);
83 UCS
*ucs4_strrchr(UCS
*s
, UCS c
);
84 unsigned utf8_width(char *);
85 size_t utf8_to_width_rhs(char *, char *, size_t, unsigned);
86 int utf8_snprintf(char *, size_t, char *, ...);
87 size_t utf8_to_width(char *, char *, size_t, unsigned, unsigned *);
88 size_t utf8_pad_to_width(char *, char *, size_t, unsigned, int);
89 unsigned utf8_truncate(char *, unsigned);
90 char *utf8_count_back_width(char *, char *, unsigned, unsigned *);
91 char *utf8_count_forw_width(char *, unsigned, unsigned *);
92 void sstrncpy(char **, char *, int);
93 int setup_for_input_output(int, char **, char **, void **, char **);
94 int input_charset_is_supported(char *);
95 int output_charset_is_supported(char *);
96 int posting_charset_is_supported(char *);
97 char *utf8_to_charset(char *, char *, int);
100 void line_paint(int, struct display_line
*, int *);
101 int pith_ucs4width(UCS
);
103 #if !defined(_WINDOWS) && HAVE_LANGINFO_H && defined(CODESET)
104 char *nl_langinfo_codeset_wrapper(void);
108 #endif /* PITH_CHARCONV_UTF8_INCLUDED */