1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#ifndef _NT_UNICODE_H_
#define _NT_UNICODE_H_
/**
* the conversion functions are based on the validation functions;
* each of the conversion functions passes its peer validation
* function an array of callback handlers, with each member of
* the array corresponding to the number of units making the
* current code point in utf-8, be that source or destination.
* following this logic, then, callback_fn[1] handles 1-byte
* code points [00..7F], callback_fn[2] handles 2-byte code
* points [C2..DF,80..BF], and so on. the first member of
* the array, callback_fn[0], is invoked once the null
* termination of the source stream has been reached.
**/
#include "nt_abi.h"
#include "nt_compiler.h"
typedef struct _nt_utf8_callback_args {
const unsigned char * src;
void * dst;
void * dst_cap;
uint32_t byte_count;
uint32_t code_point;
size_t bytes_written;
} nt_utf8_callback_args;
typedef struct _nt_utf16_callback_args {
const wchar16_t * src;
void * dst;
void * dst_cap;
uint32_t byte_count;
uint32_t code_point;
size_t bytes_written;
} nt_utf16_callback_args;
typedef struct _nt_unicode_conversion_params_utf8_to_utf16 {
const unsigned char * src;
size_t src_size_in_bytes;
wchar16_t * dst;
size_t dst_size_in_bytes;
size_t code_points;
size_t bytes_written;
const unsigned char * addr_failed;
uintptr_t leftover_count;
uintptr_t leftover_bytes;
} nt_unicode_conversion_params_utf8_to_utf16, nt_strconv_mbtonative;
typedef struct _nt_unicode_conversion_params_utf8_to_utf32 {
const unsigned char * src;
size_t src_size_in_bytes;
wchar32_t * dst;
size_t dst_size_in_bytes;
size_t code_points;
size_t bytes_written;
const unsigned char * addr_failed;
uintptr_t leftover_count;
uintptr_t leftover_bytes;
} nt_unicode_conversion_params_utf8_to_utf32, nt_strconv_mbtowide;
typedef struct _nt_unicode_conversion_params_utf16_to_utf8 {
const wchar16_t * src;
size_t src_size_in_bytes;
unsigned char * dst;
size_t dst_size_in_bytes;
size_t code_points;
size_t bytes_written;
const wchar16_t * addr_failed;
uintptr_t leftover_count;
uintptr_t leftover_bytes;
} nt_unicode_conversion_params_utf16_to_utf8, nt_strconv_nativetomb;
typedef struct _nt_unicode_conversion_params_utf16_to_utf32 {
const wchar16_t * src;
size_t src_size_in_bytes;
wchar32_t * dst;
size_t dst_size_in_bytes;
size_t code_points;
size_t bytes_written;
const wchar16_t * addr_failed;
uintptr_t leftover_count;
uintptr_t leftover_bytes;
} nt_unicode_conversion_params_utf16_to_utf32, nt_strconv_nativetowide;
__assert_aligned_size(nt_utf8_callback_args,__SIZEOF_POINTER__);
__assert_aligned_size(nt_utf16_callback_args,__SIZEOF_POINTER__);
__assert_aligned_size(nt_unicode_conversion_params_utf8_to_utf16,__SIZEOF_POINTER__);
__assert_aligned_size(nt_unicode_conversion_params_utf8_to_utf32,__SIZEOF_POINTER__);
__assert_aligned_size(nt_unicode_conversion_params_utf16_to_utf8,__SIZEOF_POINTER__);
__assert_aligned_size(nt_unicode_conversion_params_utf16_to_utf32,__SIZEOF_POINTER__);
typedef int32_t __fastcall ntapi_uc_utf8_callback_fn(
__in nt_utf8_callback_args * callback_args);
typedef int32_t __fastcall ntapi_uc_utf16_callback_fn(
__in nt_utf16_callback_args * callback_args);
typedef int32_t __stdcall ntapi_uc_validate_unicode_stream_utf8(
__in const unsigned char * ch,
__in size_t size_in_bytes __optional,
__out size_t * code_points __optional,
__out const unsigned char ** addr_failed __optional,
__in ntapi_uc_utf8_callback_fn ** callback_fn __optional,
__in nt_utf8_callback_args * callback_args __optional);
typedef int32_t __stdcall ntapi_uc_validate_unicode_stream_utf16(
__in const wchar16_t * wch,
__in size_t size_in_bytes __optional,
__out size_t * code_points __optional,
__out const wchar16_t ** addr_failed __optional,
__in ntapi_uc_utf16_callback_fn ** callback_fn __optional,
__in nt_utf16_callback_args * callback_args __optional);
typedef int __stdcall ntapi_uc_get_code_point_byte_count_utf8(
__in uint32_t code_point);
typedef int __stdcall ntapi_uc_get_code_point_byte_count_utf16(
__in uint32_t code_point);
typedef int32_t __stdcall ntapi_uc_convert_unicode_stream_utf8_to_utf16(
__in_out nt_unicode_conversion_params_utf8_to_utf16 * params);
typedef int32_t __stdcall ntapi_uc_convert_unicode_stream_utf8_to_utf32(
__in_out nt_unicode_conversion_params_utf8_to_utf32 * params);
typedef int32_t __stdcall ntapi_uc_convert_unicode_stream_utf16_to_utf8(
__in_out nt_unicode_conversion_params_utf16_to_utf8 * params);
typedef int32_t __stdcall ntapi_uc_convert_unicode_stream_utf16_to_utf32(
__in_out nt_unicode_conversion_params_utf16_to_utf32 * params);
#endif
|