/* Copyright (C) 2015-2020, Dirk Krause SPDX-License-Identifier: BSD-3-Clause */ /* WARNING: This file was generated by the dkct program (see http://dktools.sourceforge.net/ for details). Changes you make here will be lost if dkct is run again! You should modify the original source and run dkct on it. Original source: dk4rec23.ctr */ /** @file dk4rec23.c The dk4rec23 module. */ #line 72 "dk4rec23.ctr" #include "dk4conf.h" #include "dk4rec23.h" #include "dk4str8.h" #if DK4_HAVE_STRING_H #ifndef STRING_H_INCLUDED #include #define STRING_H_INCLUDED 1 #endif #endif #if DK4_HAVE_ASSERT_H #ifndef ASSERT_H_INCLUDED #include #define ASSERT_H_INCLUDED 1 #endif #endif #line 93 "dk4rec23.ctr" int dk4recode_char_to_wchar_t( wchar_t *dstb, size_t szdstb, const char *src, dk4_er_t *erp ) { int back = 0; #if DK4_USE_ASSERT assert(NULL != dstb); assert(0 < szdstb); assert(NULL != src); #endif if ((NULL != dstb) && (NULL != src) && (0 < szdstb)) { *dstb = L'\0'; if (dk4str8_len(src) < szdstb) { while ('\0' != *src) { *(dstb++) = (wchar_t)((unsigned char)(*(src++))); } *dstb = L'\0'; back = 1; } else { dk4error_set_simple_error_code(erp, DK4_E_BUFFER_TOO_SMALL); } } else { dk4error_set_simple_error_code(erp, DK4_E_INVALID_ARGUMENTS); } return back; }