-
Notifications
You must be signed in to change notification settings - Fork 2
/
wctomb.c
62 lines (47 loc) · 1.28 KB
/
wctomb.c
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
/*++
toro C Library
https://github.com/KilianKegel/toro-C-Library#toro-c-library-formerly-known-as-torito-c-library
Copyright (c) 2017-2024, Kilian Kegel. All rights reserved.
SPDX-License-Identifier: GNU General Public License v3.0
Module Name:
wctomb.c
Abstract:
Implementation of the Standard C function.
Convert a wide character to the corresponding multibyte character.
Author:
Kilian Kegel
--*/
#include <stddef.h>
#include <errno.h>
/**
Synopsis
#include <stdlib.h>
int wctomb(char* pmb, wchar_t wc);
Description
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/wctomb-wctomb-l?view=msvc-160
Paramaters
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/wctomb-wctomb-l?view=msvc-160#parameters
Returns
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/wctomb-wctomb-l?view=msvc-160#return-value
**/
int wctomb(char* pmb, wchar_t wc)
{
int nRet = -1;
do
{
if (NULL == pmb)
{
nRet = 0;
break;
}
if (256 > wc)
{
*pmb = (char)wc;
nRet = 1;
break;
}
*pmb = '\0';
errno = EILSEQ;// 42 BUGBUG errno documented by MSFT is 22;
} while (0);
return nRet;
}