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: dk4rec11.ctr
12 */
13 
14 #ifndef DK4REC11_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4REC11_H_INCLUDED 1
17 
18 
19 /**	@file
20 	String recoding from UTF-8 to UTF-16.
21 
22 	CRT on Windows: Not used.
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 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /**	Recode string from UTF-8 to UTF-16.
54 	@param	dstb	Destination buffer.
55 	@param	szdstb	Size of destination buffer (number of dk_c16-t).
56 	@param	src	Source string to convert.
57 	@param	erp	Error report, may be NULL.
58 	@return	1 on success, 0 on error.
59 
60 	Error codes:
61 	- DK4_E_INVALID_ARGUMENTS<br>
62 	  if src or dstb is NULL or szdstb is 0,
63 	- DK4_E_BUFFER_TOO_SMALL<br>
64 	  if dstb is too small,
65 	- DK4_E_SYNTAX<br>
66 	  with the number of successfully recoded characters in nelem if a
67 	  non-recodable character was found.
68 */
69 int
70 dk4recode_utf8_to_utf16(
71   dk4_c16_t *dstb, size_t szdstb, const char *src, dk4_er_t *erp
72 );
73 
74 /**	Calculate required buffer size (including final 0x0000U word)
75 	to convert from UTF-8 to UTF-16.
76 	@param	src	UTF-8 encoded source string.
77 	@param	erp	Error report, may be NULL.
78 	@return	Positive required buffer size (number of dk4_c16_t) on success,
79 	0 on error.
80 
81 	Error codes:
82 	- DK4_E_INVALID_ARGUMENTS<br>
83 	  if src is NULL,
84 	- DK4_E_MATH_OVERFLOW<br>
85 	  if the required size calculation results in mathematical overflow,
86 	- DK4_E_SYNTAX<br>
87 	  if there are errors while decoding the source string.
88 */
89 size_t
90 dk4recode_size_utf8_to_utf16(const char *src, dk4_er_t *erp);
91 
92 #ifdef __cplusplus
93 }
94 #endif
95 
96 
97 #endif
98