N 2040: Suggested Technical Corrigendum for DR 488 (c16rtomb() on wide characters encoded as multiple char16_t)


Submitter:Philipp Klaus Krause
Submission Date:2016-04-13

Suggested Technical Corrigendum

Change 7.28.1.2#3-4 from:

If s is not a null pointer, the c16rtomb function determines the number of bytes needed to represent the multibyte character that corresponds to the wide character given by c16 (including any shift sequences), and stores the multibyte character representation in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If c16 is a null wide character, a null byte is stored, preceded by any shift sequence needed to restore the initial shift state; the resulting state described is the initial conversion state.

The c16rtomb function returns the number of bytes stored in the array object (including any shift sequences). When c16 is not a valid wide character, an encoding error occurs: the function stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion state is unspecified.

To:

If s is not a null pointer, and c16 completes a sequence of char16_t corresponding to a valid multibyte character, the c16rtomb function determines the number of bytes needed to represent the multibyte character (including any shift sequences), and stores the multibyte character representation in the array whose first element is pointed to by s. At most MB_CUR_MAX bytes are stored. If the multibyte character is a null character, a null byte is stored, preceded by any shift sequence needed to restore the initial shift state; the resulting state described is the initial conversion state.

The c16rtomb function returns the number of bytes stored in the array object (including any shift sequences). If c16 does not contribute to a sequence of char16_t corresponding to a valid multibyte character an encoding error occurs: the function stores the value of the macro EILSEQ in errno and returns (size_t)(-1); the conversion state is unspecified.