124{
130
131 write_result
result = { 0 };
132
134 {
135 char const c = *source_it;
136
137
138
139
140
141
142
143
144
145 wchar_t wc[2] = { 0 };
146 int wc_used = 1;
148 {
150 const int mb_buf_size =
sizeof(
_mbBuffer(fh));
151 int mb_buf_used;
152 for (mb_buf_used = 0; mb_buf_used < mb_buf_size &&
_mbBuffer(fh)[mb_buf_used]; ++mb_buf_used)
153 {}
154
155 if (mb_buf_used > 0)
156 {
158 _ASSERTE(1 < mb_len && mb_buf_used < mb_len);
159 const int remaining_bytes = mb_len - mb_buf_used;
160 if (remaining_bytes <= (
buffer_end - source_it))
161 {
162
164
165 for (
int i = 0;
i < mb_buf_used; ++
i)
166 {
168 }
169 for (
int i = 0;
i < remaining_bytes; ++
i)
170 {
171 mb_buffer[
i + mb_buf_used] = source_it[
i];
172 }
173
174
175 for (
int i = 0;
i < mb_buf_used; ++
i)
176 {
178 }
179
181 const char*
str = mb_buffer;
182 if (mb_len == 4)
183 {
184 wc_used = 2;
185 }
187 {
189 }
190 source_it += (remaining_bytes - 1);
191 }
192 else
193 {
194
195 const auto bytes_to_add =
buffer_end - source_it;
196 _ASSERTE(mb_buf_used + bytes_to_add < mb_buf_size);
197 for (
int i = 0;
i < bytes_to_add; ++
i)
198 {
200 }
201
202 result.char_count +=
static_cast<DWORD>(bytes_to_add);
204 }
205 }
206 else
207 {
209 const auto available_bytes =
buffer_end - source_it;
210 if (mb_len <= (available_bytes))
211 {
212
214 const char*
str = source_it;
215 if (mb_len == 4)
216 {
217 wc_used = 2;
218 }
220 {
222 }
223 source_it += (mb_len - 1);
224 }
225 else
226 {
227
229 for (
int i = 0;
i < available_bytes; ++
i)
230 {
232 }
233
234 result.char_count +=
static_cast<DWORD>(available_bytes);
236 }
237 }
238 }
240 {
241
242
244
247 mb_buffer[1] = *source_it;
248
250
252 {
254 }
255 }
256 else
257 {
259 {
261 {
262
264 {
266 }
267
268
269 ++source_it;
270 }
271 else
272 {
273
276
277
278
281 }
282 }
283 else
284 {
285
287 {
289 }
290 }
291 }
292
293 ++source_it;
294
295
296
299 console_cp, 0, wc, wc_used, mb_buffer, sizeof(mb_buffer), nullptr, nullptr));
300
303
305 if (!
WriteFile(os_handle, mb_buffer,
size, &written,
nullptr))
306 {
309 }
310
311
312
313
314
315
316
317
318
320
321
323 {
325 }
326
327
328
330 {
331 wchar_t const cr =
CR;
332 if (!
WriteFile(os_handle, &cr, 1, &written,
nullptr))
333 {
336 }
337
338 if (written < 1)
339 {
341 }
342
345 }
346 }
347
349}
return __acrt_WideCharToMultiByte(code_page, 0, buffer.get(), -1, result_size !=0 ? result :nullptr, result_size, nullptr, nullptr)
_Check_return_ __forceinline unsigned short __cdecl _isleadbyte_fast_internal(_In_ unsigned char const c, _In_ _locale_t const locale)
#define _dbcsBufferUsed(i)
__inline char _utf8_no_of_trailbytes(const unsigned char c)
UINT WINAPI DECLSPEC_HOTPATCH GetConsoleOutputCP(VOID)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
static int is_utf8(const char *src)
int __cdecl _mbtowc_internal(wchar_t *pwc, const char *s, size_t n, __crt_cached_ptd_host &ptd)
size_t __cdecl __mbsrtowcs_utf8(wchar_t *dst, const char **src, size_t len, mbstate_t *ps, __crt_cached_ptd_host &ptd)