headers: Hide UTF-16 and UTF-32 functions from libmsvcrt

While these are standard C11 functions, Microsoft docs say they operate
on strings in UTF-8, instead of strings in the encoding determined by the
current locale. The MSVCRT `mbstate_t`, being an `int`, is too small for
implementations of these functions.

This commit ensures these functions are only declared for UCRT; when
targeting MSVCRT only the typedefs are available.

Reference: https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/c16rtomb-c32rtomb1?view=msvc-170
Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 3cf7203..0454ece 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -174,10 +174,6 @@
   misc/mbsinit.c \
   misc/onexit_table.c \
   misc/register_tls_atexit.c \
-  misc/uchar_c16rtomb.c \
-  misc/uchar_c32rtomb.c \
-  misc/uchar_mbrtoc16.c \
-  misc/uchar_mbrtoc32.c \
   misc/wcrtomb.c \
   stdio/_getc_nolock.c \
   stdio/_getwc_nolock.c \
diff --git a/mingw-w64-crt/misc/uchar_c16rtomb.c b/mingw-w64-crt/misc/uchar_c16rtomb.c
deleted file mode 100644
index 94a2aaa..0000000
--- a/mingw-w64-crt/misc/uchar_c16rtomb.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
- */
-/* ISO C1x Unicode utilities
- * Based on ISO/IEC SC22/WG14 9899 TR 19769 (SC22 N1326)
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  Date: 2011-09-27
- */
-
-#include <errno.h>
-#include <uchar.h>
-
-size_t c16rtomb (char *__restrict__ s,
-		 char16_t c16,
-		 mbstate_t *__restrict__ state)
-{
-/* wchar_t should compatible to char16_t on Windows */
-    return wcrtomb(s, c16, state);
-}
-
diff --git a/mingw-w64-crt/misc/uchar_c32rtomb.c b/mingw-w64-crt/misc/uchar_c32rtomb.c
deleted file mode 100644
index d05e632..0000000
--- a/mingw-w64-crt/misc/uchar_c32rtomb.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
- */
-/* ISO C1x Unicode utilities
- * Based on ISO/IEC SC22/WG14 9899 TR 19769 (SC22 N1326)
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  Date: 2011-09-27
- */
-
-#include <errno.h>
-#include <uchar.h>
-
-size_t c32rtomb (char *__restrict__ s,
-		 char32_t c32,
-		 mbstate_t *__restrict__ __UNUSED_PARAM(ps))
-{
-    if (c32 <= 0x7F) /* 7 bits needs 1 byte */
-    {
-	*s = (char)c32 & 0x7F;
-	return 1;
-    }
-    else if (c32 <= 0x7FF) /* 11 bits needs 2 bytes */
-    {
-	s[1] = 0x80 | (char)(c32 & 0x3F);
-	s[0] = 0xC0 | (char)(c32 >> 6);
-	return 2;
-    }
-    else if (c32 <= 0xFFFF) /* 16 bits needs 3 bytes */
-    {
-	s[2] = 0x80 | (char)(c32 & 0x3F);
-	s[1] = 0x80 | (char)((c32 >> 6) & 0x3F);
-	s[0] = 0xE0 | (char)(c32 >> 12);
-	return 3;
-    }
-    else if (c32 <= 0x1FFFFF) /* 21 bits needs 4 bytes */
-    {
-	s[3] = 0x80 | (char)(c32 & 0x3F);
-	s[2] = 0x80 | (char)((c32 >> 6) & 0x3F);
-	s[1] = 0x80 | (char)((c32 >> 12) & 0x3F);
-	s[0] = 0xF0 | (char)(c32 >> 18);
-	return 4;
-    }
-
-    errno = EILSEQ;
-    return (size_t)-1;
-}
-
diff --git a/mingw-w64-crt/misc/uchar_mbrtoc16.c b/mingw-w64-crt/misc/uchar_mbrtoc16.c
deleted file mode 100644
index 9de35fe..0000000
--- a/mingw-w64-crt/misc/uchar_mbrtoc16.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
- */
-/* ISO C1x Unicode utilities
- * Based on ISO/IEC SC22/WG14 9899 TR 19769 (SC22 N1326)
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  Date: 2011-09-27
- */
-
-#include <errno.h>
-#include <uchar.h>
-
-size_t mbrtoc16 (char16_t *__restrict__ pc16,
-		 const char *__restrict__ s,
-		 size_t n,
-		 mbstate_t *__restrict__ state)
-{
-/* wchar_t should compatible to char16_t on Windows */
-    return mbrtowc((wchar_t *)pc16, s, n, state);
-}
-
diff --git a/mingw-w64-crt/misc/uchar_mbrtoc32.c b/mingw-w64-crt/misc/uchar_mbrtoc32.c
deleted file mode 100644
index 825fc52..0000000
--- a/mingw-w64-crt/misc/uchar_mbrtoc32.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is part of the mingw-w64 runtime package.
- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
- */
-/* ISO C1x Unicode utilities
- * Based on ISO/IEC SC22/WG14 9899 TR 19769 (SC22 N1326)
- *
- *  THIS SOFTWARE IS NOT COPYRIGHTED
- *
- *  This source code is offered for use in the public domain. You may
- *  use, modify or distribute it freely.
- *
- *  This code is distributed in the hope that it will be useful but
- *  WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- *  DISCLAIMED. This includes but is not limited to warranties of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  Date: 2011-09-27
- */
-
-#include <errno.h>
-#include <uchar.h>
-
-size_t mbrtoc32 (char32_t *__restrict__ pc32,
-		 const char *__restrict__ s,
-		 size_t n,
-		 mbstate_t *__restrict__ __UNUSED_PARAM(ps))
-{
-    if (*s == 0)
-    {
-	*pc32 = 0;
-	return 0;
-    }
-
-    /* ASCII character - high bit unset */
-    if ((*s & 0x80) == 0)
-    {
-	*pc32 = *s;
-	return 1;
-    }
-
-    /* Multibyte chars */
-    if ((*s & 0xE0) == 0xC0) /* 110xxxxx needs 2 bytes */
-    {
-	if (n < 2)
-	    return (size_t)-2;
-
-	*pc32 = ((s[0] & 31) << 6) | (s[1] & 63);
-	return 2;
-    }
-    else if ((*s & 0xf0) == 0xE0) /* 1110xxxx needs 3 bytes */
-    {
-	if (n < 3)
-	    return (size_t)-2;
-
-	*pc32 = ((s[0] & 15) << 12) | ((s[1] & 63) << 6) | (s[2] & 63);
-	return 3;
-    }
-    else if ((*s & 0xF8) == 0xF0) /* 11110xxx needs 4 bytes */
-    {
-	if (n < 4)
-	    return (size_t)-2;
-
-	*pc32 = ((s[0] & 7) << 18) | ((s[1] & 63) << 12) | ((s[2] & 63) << 6) | (s[3] & 63);
-	return 4;
-    }
-
-    errno = EILSEQ;
-    return (size_t)-1;
-}
-
diff --git a/mingw-w64-headers/crt/uchar.h b/mingw-w64-headers/crt/uchar.h
index 019f269..7c32e70 100644
--- a/mingw-w64-headers/crt/uchar.h
+++ b/mingw-w64-headers/crt/uchar.h
@@ -47,6 +47,8 @@
 extern "C" {
 #endif
 
+#ifdef _UCRT
+
 size_t mbrtoc16 (char16_t *__restrict__ pc16,
 		 const char *__restrict__ s,
 		 size_t n,
@@ -65,6 +67,8 @@
 		 char32_t c32,
 		 mbstate_t *__restrict__ ps);
 
+#endif  /* _UCRT */
+
 #ifdef __cplusplus
 }
 #endif