The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
wchar.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file wchar.h
5 * @brief wide characters. ginnOS has one multibyte encoding, UTF-8: a
6 * wchar_t is a Unicode code point.
7 */
8
9#include <stddef.h>
10#include <stdint.h>
11
12typedef unsigned int wint_t;
13
14#define WEOF ((wint_t)-1)
15
16#ifndef WCHAR_MIN
17#define WCHAR_MIN (-2147483647 - 1)
18#define WCHAR_MAX 2147483647
19#endif
20
21/** the state of a conversion that stopped in a character (UTF-8 needs none) */
22typedef struct
23{
24 unsigned int pending; // bytes of a character still to come (not used)
25} mbstate_t;
26
27/**
28 * the character at s, of at most n bytes, into *wc (if wc is not NULL).
29 * @return the bytes it used, 0 for the null character, (size_t)-1 for
30 * bytes that are not UTF-8 (errno EILSEQ), (size_t)-2 when n
31 * stops in the character.
32 */
33size_t mbrtowc(wchar_t *wc, const char *s, size_t n, mbstate_t *state);
34/** as mbrtowc with s as a whole string: (size_t)-1 or the length */
35size_t mbrlen(const char *s, size_t n, mbstate_t *state);
36/** wc as UTF-8 at s (MB_CUR_MAX bytes of room): the bytes, or (size_t)-1 */
37size_t wcrtomb(char *s, wchar_t wc, mbstate_t *state);
38/** always 1: no conversion stops in a character */
39int mbsinit(const mbstate_t *state);
40/** a character of one byte as a wide character, or WEOF for a byte from 0x80 */
42/** a wide character of one byte as that byte, else EOF */
43int wctob(wint_t wc);
44
45size_t mbstowcs(wchar_t *dst, const char *src, size_t n);
46size_t wcstombs(char *dst, const wchar_t *src, size_t n);
47
48size_t wcslen(const wchar_t *s);
49int wcscmp(const wchar_t *a, const wchar_t *b);
50int wcsncmp(const wchar_t *a, const wchar_t *b, size_t n);
51wchar_t *wcscpy(wchar_t *dst, const wchar_t *src);
52wchar_t *wcsncpy(wchar_t *dst, const wchar_t *src, size_t n);
53wchar_t *wcschr(const wchar_t *s, wchar_t c);
54wchar_t *wcsrchr(const wchar_t *s, wchar_t c);
55wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
56int wmemcmp(const wchar_t *a, const wchar_t *b, size_t n);
57wchar_t *wmemcpy(wchar_t *dst, const wchar_t *src, size_t n);
58wchar_t *wmemmove(wchar_t *dst, const wchar_t *src, size_t n);
59wchar_t *wmemset(wchar_t *dst, wchar_t c, size_t n);
60
61/** the columns a character takes in a terminal: 0, 1 or 2; -1 if it cannot be shown */
62int wcwidth(wchar_t wc);
NULL, size_t, ptrdiff_t, offsetof.
integer types of fixed width.
the state of a conversion that stopped in a character (UTF-8 needs none)
Definition wchar.h:23
unsigned int pending
Definition wchar.h:24
wchar_t * wcsncpy(wchar_t *dst, const wchar_t *src, size_t n)
size_t mbrlen(const char *s, size_t n, mbstate_t *state)
as mbrtowc with s as a whole string: (size_t)-1 or the length
wchar_t * wmemset(wchar_t *dst, wchar_t c, size_t n)
wint_t btowc(int c)
a character of one byte as a wide character, or WEOF for a byte from 0x80
wchar_t * wcscpy(wchar_t *dst, const wchar_t *src)
int wmemcmp(const wchar_t *a, const wchar_t *b, size_t n)
wchar_t * wcsrchr(const wchar_t *s, wchar_t c)
int wcsncmp(const wchar_t *a, const wchar_t *b, size_t n)
size_t wcslen(const wchar_t *s)
wchar_t * wmemmove(wchar_t *dst, const wchar_t *src, size_t n)
int wcwidth(wchar_t wc)
the columns a character takes in a terminal: 0, 1 or 2; -1 if it cannot be shown
wchar_t * wmemchr(const wchar_t *s, wchar_t c, size_t n)
size_t wcrtomb(char *s, wchar_t wc, mbstate_t *state)
wc as UTF-8 at s (MB_CUR_MAX bytes of room): the bytes, or (size_t)-1
size_t wcstombs(char *dst, const wchar_t *src, size_t n)
size_t mbstowcs(wchar_t *dst, const char *src, size_t n)
unsigned int wint_t
Definition wchar.h:12
int wctob(wint_t wc)
a wide character of one byte as that byte, else EOF
wchar_t * wcschr(const wchar_t *s, wchar_t c)
int wcscmp(const wchar_t *a, const wchar_t *b)
int mbsinit(const mbstate_t *state)
always 1: no conversion stops in a character
size_t mbrtowc(wchar_t *wc, const char *s, size_t n, mbstate_t *state)
the character at s, of at most n bytes, into *wc (if wc is not NULL).
wchar_t * wmemcpy(wchar_t *dst, const wchar_t *src, size_t n)