wctrans_t and wctype_tAuthors: Jay Ghiron
Date: 2026-04-23
Submitted against: C23
Status: Open
Cross-references: 1035, 1062
The types wctrans_t and wctype_t are both scalar types which have
a value of zero mentioned, for example:
If
propertyidentifies a valid class of wide characters according to theLC_CTYPEcategory of the current locale, thewctypefunction returns a nonzero value that is valid as the second argument to theiswctypefunction; otherwise, it returns zero.
(C23 7.32.2.3.3 "The wctype function" paragraph 4.)
For integer types the meaning is obvious. For pointer types it is less obvious but the only answer that makes sense is that zero means null. For floating types, specifically those that support signed zeros or non-canonical representations of (positive, negative, or unsigned) zero the answer is less clear. To support uses like the following:
wctype_t c=wctype("example");
if(c){
/*...*/
}
It seems clear that anything which compares equal to zero should not be returned in success. But it is not as clear if negative zero or a non-canonical representation of (positive, negative, or unsigned) zero can be returned in failure.
Another issue with wctrans_t and wctype_t being floating types is
when those floating types support NaNs. If a signaling NaN can be
returned on success, then using the result could result in the
signaling NaN taking effect. It can occur even when copying the
value, see C23 F.3 paragraph 4. For quiet NaNs it would not have that
issue but it would still break comparisons between different values.
Though it is never actually specified that equality between different
wctrans_t values or that equality between different wctype_t
values requires them to work the same with towctrans and iswctype,
respectively.
For both wctrans and wctype, can they return negative zero or a
non-canonical representation of (positive, negative, or unsigned) zero
to indicate success?
If the answer to question one is that any value which compares equal
to zero cannot be returned on success, for both wctrans and wctype
can they return any value which compares equal to zero to indicate
failure?
For both wctrans and wctype, can they return signaling NaNs to
indicate success?
For both wctrans and wctype, can they return quiet NaNs to
indicate success?
Does equality between different wctrans_t values and equality
between different wctype_t values require that those values work the
same with towctrans and iswctype, respectively? For example,
would it be valid for an implementation to use padding bits in the
determination of towctrans and iswctype so that values which
compare equal function differently? For floating types non-canonical
representations and payloads of NaNs provide other means of
distinguishing values which compare equal. For pointer types it may
also be possible that pointers which compare equal can be
distinguished using provenance.
For both wctrans and wctype, are multiple invocations with the same
LC_CTYPE and argument required to return the same value?
Comment from Issues list maintainer on 2026-11-26:
This issue was discussed at the November 2026 (Búzios) meeting of WG14. There was support for restricting these types to be integer or pointer types, subject to research on what types existing implementations use, and Joseph Myers took an action item to ask the issue submitter to do that research and to propose wording to restrict to integer and pointer types.
Comment from Jay Ghiron on 2026-11-27:
Here are many implementations which I can observe:
wctrans_t and wctype_t are both int. There are no
locale-specific values for either wctrans_t or wctype_t, and
only the standard mappings and standard classifications are
provided. The values of wctrans_t and wctype_t are simply
integers used to represent the mappings and classifications
respectively.wctrans_t is const int32_t*. wctype_t is
unsigned long. Locale-specific values are supported. Even though
wctype_t is an integer type, it is treated as a pointer type. The
pointers used are pointers to tables that contain the information of
the mapping or classification.wctrans_t is const int*. wctype_t is unsigned long.
There are no locale-specific values for either wctrans_t or
wctype_t, and only the standard mappings and standard
classifications are provided. These types are probably chosen to
match glibc, but the values of wctrans_t and wctype_t are simply
integers used to represent the mappings and classifications
respectively.wctype_t is unsigned. There are no locale-specific
values for wctype_t, and only the standard classifications are
provided. The values of wctype_t are simply integers used to
represent the mappings and classifications respectively. It appears
that wctrans_t, as well as the functions wctrans and towctrans
are not provided.wctrans_t is wchar_t. wctype_t is unsigned short.
The source code for any of the functions using these types in
<wctype.h> is not publicly available.wctrans_t is int. wctype_t is unsigned long.
There are no locale-specific values for either wctrans_t or
wctype_t, but in addition to the standard mappings and standard
classifications there are a few non-standard classifications
provided. The values of wctrans_t are simply integers used to
represent the mappings. The values of wctype_t represent bit masks
for which classifications are included.wctrans_t and wctype_t are both void*. There are
no locale-specific values for wctype_t, and only the standard
classifications are provided. Locale-specific values are supported
for wctrans_t. The pointers used for wctype_t are pointers to
structures that contain bit masks for which classifications are
included. The pointers used for wctrans_t are pointers to tables
that contain the information of the mapping.wctrans_t is struct __tag_wctrans_t*. wctype_t is
struct __tag_wctype_t*. Locale-specific values are supported. The
pointers used are pointers to tables that contain the information of
the mapping or classification.wctrans_t is const void*. wctype_t is long. There
are no locale-specific values for either wctrans_t or wctype_t,
and only the standard mappings and standard classifications are
provided. Even though wctrans_t is a pointer type, it is treated
as an integer type. The values of wctrans_t and wctype_t are
simply integers used to represent the mappings and classifications
respectively.wctrans_t is int. wctype_t is uint32_t in sixty
four bit mode and unsigned long in thirty two bit mode. There are
no locale-specific values for wctrans_t, and only the standard
mappings are provided. Locale-specific values are supported for
wctype_t. The values of wctrans_t are simply integers used to
represent the mappings. The values of wctype_t represent bit masks
for which classifications are included.As an aside, while looking at these implementations I noticed that
there is disagreement about whether wctrans and towctrans set
errno to EINVAL. newlib, FreeBSD libc, Bionic, and Apple libc set
errno to EINVAL in wctrans for an invalid mapping name. FreeBSD
libc, OpenBSD libc, NetBSD libc, Bionic, and Apple libc set errno to
EINVAL in towctrans when the wctrans_t parameter is zero. newlib
would also set errno to EINVAL in towctrans when the wctrans_t
parameter is zero, but it appears that has been commented out.
No implementations that I have seen define either wctrans_t or
wctype_t as a floating type.