Donny9 commented on code in PR #6666:
URL: https://github.com/apache/incubator-nuttx/pull/6666#discussion_r930022597


##########
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 <= 0xffff)
+    {
+      *s++ = 0xe0 | (wc >> 12);
+      *s++ = 0x80 | ((wc >> 6) & 0x3f);
+      *s = 0x80 | (wc & 0x3f);
+      return 3;
     }
-  else
+  else if ((unsigned)wc < 0x110000)

Review Comment:
   Done!



-- 
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

Reply via email to