-/* c16rtomb(\r
- char *restrict s, \r
- char16_t c16,\r
- mbstate_t *restrict ps);\r
+/* c16rtomb( char *, char16_t, mbstate_t * )\r
\r
This file is part of the Public Domain C Library (PDCLib).\r
Permission is granted to use, modify, and / or redistribute at will.\r
#include <stdint.h>\r
#include <assert.h>\r
#include <stdlib.h>\r
-#include <_PDCLIB_encoding.h>\r
-#include <_PDCLIB_locale.h>\r
+#include "_PDCLIB_encoding.h"\r
+#include "_PDCLIB_locale.h"\r
\r
size_t c16rtomb_l(\r
char *restrict s, \r
)\r
{\r
const char16_t *restrict psrc = &c16;\r
+ char buf[s ? 0 : MB_CUR_MAX];\r
+ s = s ? s : buf;\r
\r
if(!l->_Codec->__c16stombs) {\r
// Codec doesn't support direct conversion - translate via UCS-4\r
if((c16 & 0xFC00) == 0xDC00) {\r
// Trailing surrogate\r
char32_t c32 = (ps->_Surrogate & 0x3FF) << 10 | (c16 & 0x3FF);\r
+ ps->_Surrogate = 0;\r
return c32rtomb_l(s, c32, ps, l);\r
} else {\r
// Not a trailing surrogate - encoding error\r
#endif\r
\r
#ifdef TEST\r
-#include <_PDCLIB_test.h>\r
+#include "_PDCLIB_test.h"\r
\r
int main( void )\r
{\r