pkarashchenko commented on code in PR #6666: URL: https://github.com/apache/incubator-nuttx/pull/6666#discussion_r929724629
########## libs/libc/wchar/lib_wcrtomb.c: ########## @@ -57,18 +51,37 @@ size_t wcrtomb(FAR char *s, wchar_t wc, FAR mbstate_t *ps) { - int retval = 0; - char buf[MB_LEN_MAX]; - if (s == NULL) { - retval = wctomb(buf, wc); + return 0; + } + else if ((unsigned)wc < 0x80) + { + *s = wc; + return 1; + } + else if ((unsigned)wc < 0x800) + { + *s++ = 0xc0 | (wc >> 6); + *s = 0x80 | (wc & 0x3f); + return 2; + } + else if ((unsigned)wc < 0xd800 || (unsigned)wc - 0xe000 < 0x2000) + { + *s++ = 0xe0 | (wc >> 12); + *s++ = 0x80 | ((wc >> 6) & 0x3f); + *s = 0x80 | (wc & 0x3f); + return 3; } - else + else if ((unsigned)wc - 0x10000 < 0x100000) Review Comment: this is still not answered. `0x100000` is out of `unsinged` value change for platforms with 16bit int. Let me double check if `(unsigned)wc - 0x10000 < 0x100000` will be alway `true` or not. I need to refresh my knowledge about type promotion during arithmetic and compare operations in C. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org