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: dk4rec03.ctr
12 */
13 
14 #ifndef DK4REC03_H_INCLUDED
15 /** Avoid multiple inclusions. */
16 #define DK4REC03_H_INCLUDED 1
17 
18 
19 /**	@file
20 	String recoding from ASCII to UTF-8.
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 ASCII to UTF-8.
54 	@param	dstb	Destination buffer.
55 	@param	szdstb	Size of destination buffer (number of bytes).
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_ascii_to_utf8(
71   char *dstb, size_t szdstb, const char *src, dk4_er_t *erp
72 );
73 
74 /**	Calculate required buffer size (including final 0x00 byte)
75 	for ASCII to UTF-8 conversion.
76 	@param	src	ASCII encoded string.
77 	@param	erp	Error report, may be NULL.
78 	@return	Positive value on success, 0 on error.
79 
80 	Error codes:
81 	- DK4_E_INVALID_ARGUMENTS<br>
82 	  if src is NULL,
83 	- DK4_E_SYNTAX<br>
84 	  if there are encoding errors,
85 	- DK4_E_MATH_OVERFLOW<br>
86 	  if a numeric overflow occured in size calculation.
87 */
88 size_t
89 dk4recode_size_ascii_to_utf8(const char *src, dk4_er_t *erp);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 
95 
96 #endif
97