The test case that I sent uses UTF-8 encoding.

Here's another test case, that uses GB18030 (supposedly supported
since Cygwin 3.5.0). It fails as well, in line 26.

On glibc systems, this test works.

#include <assert.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uchar.h>
#include <wchar.h>

int main ()
{
  assert (setlocale (LC_ALL, "zh_CN.GB18030") != NULL);
  mbstate_t state;
  memset (&state, 0, sizeof (state));

  char32_t uc = 0xDEADBEEF;
  size_t bytes;

  /* \224\071\311\067 = U+0001F403 */
  bytes = mbrtoc32 (&uc, "\224", 1, &state);
  assert (bytes == (size_t)-2);
  bytes = mbrtoc32 (&uc, "\071", 1, &state);
  assert (bytes == (size_t)-2);
  bytes = mbrtoc32 (&uc, "\311", 1, &state);
  assert (bytes == (size_t)-2);
  bytes = mbrtoc32 (&uc, "\067", 1, &state);
  assert (bytes == 1);
  assert (uc == 0x0001F403);
}

/* Works in: glibc
   Fails in: Cygwin 3.5.3
 */
-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
  • an mbrtoc32 bug Bruno Haible via Cygwin
    • Re: an mbrtoc32 bug Bruno Haible via Cygwin

Reply via email to