This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[1.7] wctomb bug


Simple test case.  This application uses the C locale (by virtue of the fact 
that we did not use setlocale(), and evidenced by mb_cur_max of 1).  On Linux, 
this correctly shows wctomb rejecting the conversion (0x100 is too big to fit 
in a 1-byte sequence) with EILSEQ, but newlib currently truncates the invalid 
wchar_t value to int and returns 1.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <wchar.h>
#include <string.h>
#include <limits.h>

int main (int argc, char **argv)
{
   wchar_t w = 0x100;
   char str[MB_LEN_MAX];
   int i = wctomb(str, w);
   printf("mb_cur_max %zd, len %d, str[0] 0x%02hhx, errno %d\n",
          MB_CUR_MAX, i, str[0], errno);
   return 0;
}

-- 
Eric Blake



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]