1 /*
2 Copyright (C) 2015-2021, Dirk Krause
3 SPDX-License-Identifier: BSD-3-Clause
4 */
5 
6 /*
7 	WARNING: This file was generated by the dkct program (see
8 	http://dktools.sourceforge.net/ for details).
9 	Changes you make here will be lost if dkct is run again!
10 	You should modify the original source and run dkct on it.
11 	Original source: dk4enc.ctr
12 */
13 
14 #ifndef DK4ENC_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4ENC_H_INCLUDED 1
17 
18 
19 /**	@file
20 	File and memory encodings for characters.
21 
22 	CRT on Windows: Optional, disabling CRT degrades performance.
23 */
24 
25 #ifndef DK4CONF_H_INCLUDED
26 #if DK4_BUILDING_DKTOOLS4
27 #include "dk4conf.h"
28 #else
29 #include <dktools-4/dk4conf.h>
30 #endif
31 #endif
32 
33 #ifndef DK4TYPES_H_INCLUDED
34 #if DK4_BUILDING_DKTOOLS4
35 #include <libdk4base/dk4types.h>
36 #else
37 #include <dktools-4/dk4types.h>
38 #endif
39 #endif
40 
41 #ifndef DK4ERROR_H_INCLUDED
42 #if DK4_BUILDING_DKTOOLS4
43 #include <libdk4base/dk4error.h>
44 #else
45 #include <dktools-4/dk4error.h>
46 #endif
47 #endif
48 
49 
50 
51 /**	Encodings for text files.
52 */
53 enum {
54 				/**	Bytes 0x00 to 0xff represent
55 					U+0000 to U+00FF.
56 					Formerly misleading named "ASCII".
57 				*/
58   DK4_FILE_ENCODING_PLAIN	=	0,
59 
60 				/**	Encoding used in Windows GUI programs.
61 				*/
62   DK4_FILE_ENCODING_WIN1252 ,
63 
64 				/**	UTF-8 encoding used on Linux and Unix.
65 				*/
66   DK4_FILE_ENCODING_UTF8 ,
67 
68 				/**	UTF-16 encoding, least significant
69 					byte first.
70 				*/
71   DK4_FILE_ENCODING_UTF16_LE ,
72 
73 				/**	UTF-16 encoding, most significant
74 					byte first.
75 				*/
76   DK4_FILE_ENCODING_UTF16_BE ,
77 
78 				/**	32-bit unicode characters, least
79 					significant byte first.
80 				*/
81   DK4_FILE_ENCODING_32_LE ,
82 
83 				/**	32-bit unicode characters, most
84 					significant byte first.
85 				*/
86   DK4_FILE_ENCODING_32_BE
87 
88 };
89 
90 /**	Encoding for characters in memory.
91 */
92 enum {
93 			/**	Bytes 0x00 to 0xFF represent U+0000 to U+00FF.
94 			*/
95   DK4_ENCODING_PLAIN	=	DK4_FILE_ENCODING_PLAIN,
96 
97 			/**	Encoding used by Windows GUI programs.
98 			*/
99   DK4_ENCODING_WIN1252	=	DK4_FILE_ENCODING_WIN1252,
100 
101 			/**	UTF-8 encoding used on Linux and Unix.
102 			*/
103   DK4_ENCODING_UTF8	=	DK4_FILE_ENCODING_UTF8,
104 
105 #if DK4_WORDS_BIGENDIAN
106 
107 			/**	UTF-16 encoding.
108 			*/
109   DK4_ENCODING_UTF16	=	DK4_FILE_ENCODING_UTF16_BE ,
110 
111 			/**	32-bit unicode characters.
112 			*/
113   DK4_ENCODING_32	=	DK4_FILE_ENCODING_32_BE
114 
115 #else
116 
117 			/**	UTF-16 encoding.
118 			*/
119   DK4_ENCODING_UTF16	=	DK4_FILE_ENCODING_UTF16_LE ,
120 
121 			/**	32-bit unicode characters.
122   			*/
123   DK4_ENCODING_32	=	DK4_FILE_ENCODING_32_LE
124 
125 #endif
126 
127 };
128 
129 
130 
131 #ifdef __cplusplus
132 extern "C" {
133 #endif
134 
135 /**	Find encoding by name.
136 	@param	encptr	Pointer to result variable for encoding.
137 	@param	bomptr	Pointer to result variable for BOM writing.
138 	@param	src	Source text containing encoding name.
139 	@param	erp	Error report, may be NULL.
140 	@return	1 on success, 0 on error.
141 
142 	Error codes:
143 	- DK4_E_INVALID_ARGUMENTS<br>
144 	  if encptr or src is NULL,
145 	- DK4_E_BUFFER_TOO_SMALL<br>
146 	  if the text is too long to create a local copy for modification, or
147 	- DK4_E_SYNTAX<br>
148 	  if invalid encoding, options or encoding/option combinations are
149 	  specified.
150 */
151 int
152 dk4enc_find(int *encptr, int *bomptr, const dkChar *src, dk4_er_t *erp);
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 
159 
160 
161 #endif
162