Index: abi/include/_bits/mbstate_t.h
===================================================================
--- abi/include/_bits/mbstate_t.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ abi/include/_bits/mbstate_t.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup bits
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _BITS_MBSTATE_T_H_
+#define _BITS_MBSTATE_T_H_
+
+typedef struct {
+	unsigned short continuation;
+} mbstate_t;
+
+#endif
+
+/** @}
+ */
Index: abi/include/_bits/uchar.h
===================================================================
--- abi/include/_bits/uchar.h	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ abi/include/_bits/uchar.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -46,5 +46,6 @@
 #endif
 
-typedef uint32_t char32_t;
+typedef uint_least16_t char16_t;
+typedef uint_least32_t char32_t;
 
 #endif
Index: common/include/uchar.h
===================================================================
--- common/include/uchar.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ common/include/uchar.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libc
+ * @{
+ */
+/** @file
+ */
+
+#ifndef _LIBC_UCHAR_H_
+#define _LIBC_UCHAR_H_
+
+#include <_bits/mbstate_t.h>
+#include <_bits/size_t.h>
+#include <_bits/uchar.h>
+#include <stdint.h>
+
+size_t mbrtoc8(char8_t *__restrict pc8, const char *__restrict s, size_t n,
+    mbstate_t *__restrict ps);
+size_t c8rtomb(char *__restrict s, char8_t c8, mbstate_t *__restrict ps);
+size_t mbrtoc16(char16_t *__restrict pc16, const char *__restrict s, size_t n,
+    mbstate_t *__restrict ps);
+size_t c16rtomb(char *__restrict s, char16_t c16, mbstate_t *__restrict ps);
+size_t mbrtoc32(char32_t *__restrict pc32, const char *__restrict s, size_t n,
+    mbstate_t *__restrict ps);
+size_t c32rtomb(char *__restrict s, char32_t c32, mbstate_t *__restrict ps);
+
+#ifdef _HELENOS_SOURCE
+#define UCHAR_ILSEQ      ((size_t) -1)
+#define UCHAR_INCOMPLETE ((size_t) -2)
+#define UCHAR_CONTINUED  ((size_t) -3)
+#endif
+
+#endif
+
+/** @}
+ */
Index: common/include/wchar.h
===================================================================
--- common/include/wchar.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ common/include/wchar.h	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _LIBC_WCHAR_H_
+#define _LIBC_WCHAR_H_
+
+#include <_bits/NULL.h>
+#include <_bits/WEOF.h>
+#include <_bits/mbstate_t.h>
+#include <_bits/size_t.h>
+#include <_bits/wchar_limits.h>
+#include <_bits/wchar_t.h>
+#include <_bits/wint_t.h>
+#include <stdarg.h>
+
+/* Forward declarations for types. */
+typedef struct _IO_FILE FILE;
+struct tm;
+
+/*
+ * Complete list of functions straight out of ISO/IEC 9899:2023 (N3096 draft).
+ * Only some of these are implemented, but keep all standard prototypes here
+ * for less pain in libposix etc.
+ */
+
+int fputws(const wchar_t *__restrict__, FILE *__restrict__);
+int fwide(FILE *, int mode);
+int fwprintf(FILE *__restrict__, const wchar_t *__restrict__, ...);
+int fwscanf(FILE *__restrict__, const wchar_t *__restrict__, ...);
+int mbsinit(const mbstate_t *);
+int swprintf(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, ...);
+int swscanf(const wchar_t *__restrict__, const wchar_t *__restrict__, ...);
+int vfwprintf(FILE *__restrict__, const wchar_t *__restrict__, va_list);
+int vfwscanf(FILE *__restrict__, const wchar_t *__restrict__, va_list);
+int vswprintf(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list);
+int vswscanf(const wchar_t *__restrict__, const wchar_t *__restrict__, va_list);
+int vwprintf(const wchar_t *__restrict__, va_list);
+int vwscanf(const wchar_t *__restrict__, va_list);
+int wcscmp(const wchar_t *, const wchar_t *);
+int wcscoll(const wchar_t *, const wchar_t *);
+int wcsncmp(const wchar_t *, const wchar_t *, size_t);
+int wctob(wint_t);
+int wmemcmp(const wchar_t *, const wchar_t *, size_t);
+int wprintf(const wchar_t *__restrict__, ...);
+int wscanf(const wchar_t *__restrict__, ...);
+long int wcstol(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+long long int wcstoll(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+size_t mbrlen(const char *__restrict__, size_t, mbstate_t *__restrict__);
+size_t mbrtowc(wchar_t *__restrict__ pwc, const char *__restrict__, size_t, mbstate_t *__restrict__);
+size_t mbsrtowcs(wchar_t *__restrict__ dst, const char **__restrict__ src, size_t, mbstate_t *__restrict__);
+size_t wcrtomb(char *__restrict__, wchar_t wc, mbstate_t *__restrict__);
+size_t wcscspn(const wchar_t *, const wchar_t *);
+size_t wcsftime(wchar_t *__restrict__, size_t maxsize, const wchar_t *__restrict__, const struct tm *__restrict__ timeptr);
+size_t wcslen(const wchar_t *);
+size_t wcsrtombs(char *__restrict__ dst, const wchar_t **__restrict__ src, size_t, mbstate_t *__restrict__);
+size_t wcsspn(const wchar_t *, const wchar_t *);
+size_t wcsxfrm(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
+unsigned long int wcstoul(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+unsigned long long int wcstoull(const wchar_t *__restrict__, wchar_t **__restrict__, int);
+wchar_t *fgetws(wchar_t *__restrict__, int, FILE *__restrict__);
+wchar_t *wcscat(wchar_t *__restrict__, const wchar_t *__restrict__);
+wchar_t *wcscpy(wchar_t *__restrict__, const wchar_t *__restrict__);
+wchar_t *wcsncat(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
+wchar_t *wcsncpy(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
+wchar_t *wcstok(wchar_t *__restrict__, const wchar_t *__restrict__, wchar_t **__restrict__);
+wchar_t *wmemcpy(wchar_t *__restrict__, const wchar_t *__restrict__, size_t);
+wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t);
+wchar_t *wmemset(wchar_t *, wchar_t, size_t);
+wint_t btowc(int);
+wint_t fgetwc(FILE *);
+wint_t fputwc(wchar_t, FILE *);
+wint_t getwc(FILE *);
+wint_t getwchar(void);
+wint_t putwc(wchar_t, FILE *);
+wint_t putwchar(wchar_t);
+wint_t ungetwc(wint_t, FILE *);
+
+// TODO: In C23, these functions have generic macro definitions for correct
+//       const handling.
+wchar_t *wcschr(const wchar_t *, wchar_t);
+wchar_t *wcspbrk(const wchar_t *, const wchar_t *);
+wchar_t *wcsrchr(const wchar_t *, wchar_t);
+wchar_t *wcsstr(const wchar_t *, const wchar_t *);
+wchar_t *wmemchr(const wchar_t *, wchar_t, size_t);
+
+#endif /* _LIBC_WCHAR_H_ */
Index: common/stdc/uchar.c
===================================================================
--- common/stdc/uchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ common/stdc/uchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <assert.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <uchar.h>
+
+#if __STDC_HOSTED__
+#include <fibril.h>
+#endif
+
+static void _set_ilseq()
+{
+#ifdef errno
+	errno = EILSEQ;
+#endif
+}
+
+static bool _is_low_surrogate(char16_t c)
+{
+	return c >= 0xDC00 && c < 0xE000;
+}
+
+static bool _is_high_surrogate(char16_t c)
+{
+	return c >= 0xD800 && c < 0xDC00;
+}
+
+static bool _is_surrogate(char16_t c)
+{
+	return c >= 0xD800 && c < 0xE000;
+}
+
+static bool _is_continuation(uint8_t c)
+{
+	return (c & 0xC0) == 0x80;
+}
+
+static bool _is_1_byte(uint8_t c)
+{
+	return (c & 0x80) == 0;
+}
+
+static bool _is_2_byte(uint8_t c)
+{
+	return (c & 0xE0) == 0xC0;
+}
+
+static bool _is_3_byte(uint8_t c)
+{
+	return (c & 0xF0) == 0xE0;
+}
+
+static bool _is_4_byte(uint8_t c)
+{
+	return (c & 0xF8) == 0xF0;
+}
+
+size_t mbrtoc32(char32_t *c, const char *s, size_t n, mbstate_t *mb)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state = { };
+
+	if (!mb)
+		mb = &global_state;
+#else
+	assert(mb);
+#endif
+
+	if (n == 0)
+		return UCHAR_INCOMPLETE;
+
+	char32_t dummy;
+
+	if (!c)
+		c = &dummy;
+
+	if (!s) {
+		// Equivalent to mbrtoc32(NULL, "", 1, mb).
+		if (mb->continuation) {
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		} else {
+			return 0;
+		}
+	}
+
+	size_t i = 0;
+
+	if (!mb->continuation) {
+		/* Clean slate, read initial byte. */
+
+		uint8_t b = s[i++];
+
+		if (_is_1_byte(b)) {
+			*c = b;
+			return b == 0 ? 0 : 1;
+		}
+
+		if (_is_continuation(b)) {
+			/* unexpected continuation byte */
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		}
+
+		/*
+		 * The value stored into `continuation` is designed to have
+		 * just enough leading ones that after shifting in one less than
+		 * the expected number of continuation bytes, the most significant
+		 * bit becomes zero. (The field is 16b wide.)
+		 */
+
+		if (_is_2_byte(b)) {
+			/* 2 byte encoding               110xxxxx */
+			mb->continuation = b ^ 0b0000000011000000;
+
+		} else if (_is_3_byte(b)) {
+			/* 3 byte encoding               1110xxxx */
+			mb->continuation = b ^ 0b1111110011100000;
+
+		} else if (_is_4_byte(b)) {
+			/* 4 byte encoding               11110xxx */
+			mb->continuation = b ^ 0b1111111100000000;
+		}
+	}
+
+	while (i < n) {
+		/* Read continuation bytes. */
+
+		if (!_is_continuation(s[i])) {
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		}
+
+		/* Top bit becomes zero just before the last byte is shifted in. */
+		if (!(mb->continuation & 0x8000)) {
+			*c = ((char32_t) mb->continuation) << 6 | (s[i++] & 0x3f);
+			mb->continuation = 0;
+			return i;
+		}
+
+		mb->continuation = mb->continuation << 6 | (s[i++] & 0x3f);
+	}
+
+	return UCHAR_INCOMPLETE;
+}
+
+#define UTF8_CONT(c, shift) (0x80 | (((c) >> (shift)) & 0x3F))
+
+size_t c32rtomb(char *s, char32_t c, mbstate_t *mb)
+{
+	if (!s) {
+		// Equivalent to c32rtomb(buf, L’\0’, mb).
+		return 1;
+	}
+
+	/* 1 byte encoding */
+	if (c < 0x80) {
+		s[0] = c;
+		return 1;
+	}
+
+	/* 2 byte encoding */
+	if (c < 0x800) {
+		s[0] = 0b11000000 | (c >> 6);
+		s[1] = UTF8_CONT(c, 0);
+		return 2;
+	}
+
+	/* 3 byte encoding */
+	if (c < 0x10000) {
+		if (_is_surrogate(c)) {
+			/* illegal range for an unicode code point */
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		}
+
+		s[0] = 0b11100000 | (c >> 12);
+		s[1] = UTF8_CONT(c, 6);
+		s[2] = UTF8_CONT(c, 0);
+		return 3;
+	}
+
+	/* 4 byte encoding */
+	if (c < 0x110000) {
+		s[0] = 0b11110000 | (c >> 18);
+		s[1] = UTF8_CONT(c, 12);
+		s[2] = UTF8_CONT(c, 6);
+		s[3] = UTF8_CONT(c, 0);
+		return 4;
+	}
+
+	_set_ilseq();
+	return UCHAR_ILSEQ;
+}
+
+size_t mbrtoc16(char16_t *c, const char *s, size_t n, mbstate_t *mb)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state = { };
+
+	if (!mb)
+		mb = &global_state;
+#else
+	assert(mb);
+#endif
+
+	char16_t dummy;
+
+	if (!c)
+		c = &dummy;
+
+	if (!s) {
+		/* Equivalent to mbrtoc16(NULL, "", 1, mb). */
+		if (mb->continuation) {
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		} else {
+			return 0;
+		}
+	}
+
+	if ((mb->continuation & 0xD000) == 0xD000) {
+		/* mbstate_t contains the second surrogate character. */
+		/* mbrtoc32() will never set it to such value.        */
+		*c = mb->continuation;
+		mb->continuation = 0;
+		return UCHAR_CONTINUED;
+	}
+
+	char32_t c32 = 0;
+	size_t ret = mbrtoc32(&c32, s, n, mb);
+	if (ret < INT_MAX) {
+		if (c32 < 0x10000) {
+			*c = c32;
+		} else {
+			/* Encode UTF-16 surrogates. */
+			mb->continuation = (c32 & 0x3FF) + 0xDC00;
+			*c = (c32 >> 10) + 0xD7C0;
+		}
+		return ret;
+	}
+
+	return ret;
+}
+
+size_t c16rtomb(char *s, char16_t c, mbstate_t *mb)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state = { };
+
+	if (!mb)
+		mb = &global_state;
+#else
+	assert(mb);
+#endif
+
+	if (!s) {
+		// Equivalent to c16rtomb(buf, L’\0’, mb).
+		if (mb->continuation) {
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		} else {
+			return 1;
+		}
+	}
+
+	if (!_is_surrogate(c)) {
+		if (mb->continuation) {
+			_set_ilseq();
+			return UCHAR_ILSEQ;
+		}
+
+		return c32rtomb(s, c, mb);
+	}
+
+	if (!mb->continuation) {
+		mb->continuation = c;
+		return 0;
+	}
+
+	char32_t c32;
+
+	/* Decode UTF-16 surrogates. */
+	if (_is_low_surrogate(mb->continuation) && _is_high_surrogate(c)) {
+		c32 = ((c - 0xD7C0) << 10) | (mb->continuation - 0xDC00);
+	} else if (_is_high_surrogate(mb->continuation) && _is_low_surrogate(c)) {
+		c32 = ((mb->continuation - 0xD7C0) << 10) | (c - 0xDC00);
+	} else {
+		_set_ilseq();
+		return UCHAR_ILSEQ;
+	}
+
+	mb->continuation = 0;
+	return c32rtomb(s, c32, mb);
+}
Index: common/stdc/wchar.c
===================================================================
--- common/stdc/wchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ common/stdc/wchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <uchar.h>
+#include <wchar.h>
+
+#if __STDC_HOSTED__
+#include <fibril.h>
+#endif
+
+wint_t btowc(int c)
+{
+	return (c < 0x80) ? c : WEOF;
+}
+
+int wctob(wint_t c)
+{
+	return c;
+}
+
+int mbsinit(const mbstate_t *ps)
+{
+	return ps == NULL || ps->continuation == 0;
+}
+
+size_t mbrlen(const char *s, size_t n, mbstate_t *ps)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state;
+	if (!ps)
+		ps = &global_state;
+#endif
+
+	return mbrtowc(NULL, s, n, ps);
+}
+
+_Static_assert(sizeof(wchar_t) == sizeof(char16_t) || sizeof(wchar_t) == sizeof(char32_t));
+
+size_t mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state;
+	if (!ps)
+		ps = &global_state;
+#endif
+
+	if (sizeof(wchar_t) == sizeof(char16_t))
+		return mbrtoc16((char16_t *) pwc, s, n, ps);
+	else
+		return mbrtoc32((char32_t *) pwc, s, n, ps);
+}
+
+size_t wcrtomb(char *s, wchar_t wc, mbstate_t * ps)
+{
+#if __STDC_HOSTED__
+	static fibril_local mbstate_t global_state;
+	if (!ps)
+		ps = &global_state;
+#endif
+
+	if (sizeof(wchar_t) == sizeof(char16_t))
+		return c16rtomb(s, (char16_t) wc, ps);
+	else
+		return c32rtomb(s, (char32_t) wc, ps);
+}
Index: rnel/generic/include/uchar.h
===================================================================
--- kernel/generic/include/uchar.h	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2020 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup kernel_generic
- * @{
- */
-/** @file
- */
-
-#ifndef _KERN_UCHAR_H_
-#define _KERN_UCHAR_H_
-
-#include <_bits/uchar.h>
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/uchar.h
===================================================================
--- uspace/lib/c/include/uchar.h	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ 	(revision )
@@ -1,43 +1,0 @@
-/*
- * Copyright (c) 2020 Martin Decky
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_UCHAR_H_
-#define _LIBC_UCHAR_H_
-
-#include <_bits/uchar.h>
-
-#endif
-
-/** @}
- */
Index: pace/lib/c/include/wchar.h
===================================================================
--- uspace/lib/c/include/wchar.h	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ 	(revision )
@@ -1,53 +1,0 @@
-/*
- * Copyright (c) 2017 CZ.NIC, z.s.p.o.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * - The name of the author may not be used to endorse or promote products
- *   derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*
- * Authors:
- *	Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
- */
-
-/** @addtogroup libc
- * @{
- */
-/** @file
- */
-
-#ifndef _LIBC_WCHAR_H_
-#define _LIBC_WCHAR_H_
-
-#include <_bits/size_t.h>
-#include <_bits/wchar_t.h>
-#include <_bits/wchar_limits.h>
-#include <_bits/wint_t.h>
-#include <_bits/NULL.h>
-#include <_bits/WEOF.h>
-
-#endif
-
-/** @}
- */
Index: uspace/lib/c/meson.build
===================================================================
--- uspace/lib/c/meson.build	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ uspace/lib/c/meson.build	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -71,4 +71,6 @@
 	'common/stdc/qsort.c',
 	'common/stdc/calloc.c',
+	'common/stdc/uchar.c',
+	'common/stdc/wchar.c',
 	'common/gsort.c',
 	'common/str.c',
@@ -196,4 +198,5 @@
 	'test/string.c',
 	'test/strtol.c',
+	'test/uchar.c',
 	'test/uuid.c',
 )
Index: uspace/lib/c/test/main.c
===================================================================
--- uspace/lib/c/test/main.c	(revision 7d1497cf9605db81e6e6f5acc0f6323496e8bfdb)
+++ uspace/lib/c/test/main.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -57,4 +57,5 @@
 PCUT_IMPORT(strtol);
 PCUT_IMPORT(table);
+PCUT_IMPORT(uchar);
 PCUT_IMPORT(uuid);
 
Index: uspace/lib/c/test/uchar.c
===================================================================
--- uspace/lib/c/test/uchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
+++ uspace/lib/c/test/uchar.c	(revision 696b405386c8f231d8955f78acc39dd81137ea5c)
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2025 Jiří Zárevúcky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <mem.h>
+#include <pcut/pcut.h>
+#include <stdio.h>
+#include <uchar.h>
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(uchar);
+
+PCUT_TEST(mbrtoc16)
+{
+	mbstate_t mbstate;
+	memset(&mbstate, 0, sizeof(mbstate));
+
+	size_t ret;
+	const char *s = u8"a𐎣";
+	char16_t out[] = u"AAAAA";
+	const char16_t expected[] = u"a𐎣";
+
+	ret = mbrtoc16(&out[0], s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(1, ret);
+	PCUT_ASSERT_INT_EQUALS(expected[0], out[0]);
+
+	s += ret;
+
+	ret = mbrtoc16(&out[1], s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(4, ret);
+	PCUT_ASSERT_INT_EQUALS(expected[1], out[1]);
+
+	s += ret;
+
+	ret = mbrtoc16(&out[2], s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(-3, ret);
+	PCUT_ASSERT_INT_EQUALS(expected[2], out[2]);
+
+	ret = mbrtoc16(&out[3], s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(0, ret);
+	PCUT_ASSERT_INT_EQUALS(expected[3], out[3]);
+}
+
+PCUT_TEST(c16rtomb)
+{
+	mbstate_t mbstate;
+	memset(&mbstate, 0, sizeof(mbstate));
+
+	const char16_t in[] = u"aβℷ𐎣";
+	char out[] = "AAAAAAAAAAAAAAAAA";
+
+	char *s = out;
+
+	for (size_t i = 0; i < sizeof(in) / sizeof(char16_t); i++) {
+		s += c16rtomb(s, in[i], &mbstate);
+	}
+
+	const char expected[] = u8"aβℷ𐎣";
+	PCUT_ASSERT_STR_EQUALS(expected, out);
+	PCUT_ASSERT_INT_EQUALS(s - out, sizeof(expected));
+}
+
+PCUT_TEST(mbrtoc32)
+{
+	mbstate_t mbstate;
+	memset(&mbstate, 0, sizeof(mbstate));
+
+	size_t ret;
+	char32_t c = 0;
+	const char *s = u8"aβℷ𐎣";
+
+	ret = mbrtoc32(&c, s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, 1);
+	PCUT_ASSERT_INT_EQUALS(c, U'a');
+
+	s += ret;
+
+	ret = mbrtoc32(&c, s, 1, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, -2);
+	PCUT_ASSERT_INT_EQUALS(c, U'a');
+
+	s += 1;
+
+	ret = mbrtoc32(&c, s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, 1);
+	PCUT_ASSERT_INT_EQUALS(c, U'β');
+
+	s += ret;
+
+	ret = mbrtoc32(&c, s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, 3);
+	PCUT_ASSERT_INT_EQUALS(c, U'ℷ');
+
+	s += ret;
+
+	ret = mbrtoc32(&c, s, 3, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, -2);
+	PCUT_ASSERT_INT_EQUALS(c, U'ℷ');
+
+	s += 3;
+
+	ret = mbrtoc32(&c, s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, 1);
+	PCUT_ASSERT_INT_EQUALS(c, U'𐎣');
+
+	s += ret;
+
+	ret = mbrtoc32(&c, s, MB_CUR_MAX, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(ret, 0);
+	PCUT_ASSERT_INT_EQUALS(c, 0);
+}
+
+PCUT_TEST(c32rtomb)
+{
+	mbstate_t mbstate;
+	memset(&mbstate, 0, sizeof(mbstate));
+
+	char out[] = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+	char *s = out;
+
+	_Static_assert(sizeof(out) > 5 * MB_CUR_MAX);
+
+	s += c32rtomb(s, U'a', &mbstate);
+	PCUT_ASSERT_INT_EQUALS(s - out, 1);
+
+	s += c32rtomb(s, U'β', &mbstate);
+	PCUT_ASSERT_INT_EQUALS(s - out, 3);
+
+	s += c32rtomb(s, U'ℷ', &mbstate);
+	PCUT_ASSERT_INT_EQUALS(s - out, 6);
+
+	s += c32rtomb(s, U'𐎣', &mbstate);
+	PCUT_ASSERT_INT_EQUALS(s - out, 10);
+
+	s += c32rtomb(s, 0, &mbstate);
+	PCUT_ASSERT_INT_EQUALS(s - out, 11);
+
+	const char expected[] = u8"aβℷ𐎣";
+	PCUT_ASSERT_INT_EQUALS(memcmp(out, expected, sizeof(expected)), 0);
+}
+
+PCUT_EXPORT(uchar);
