X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fuchar%2Fc16rtomb.c;h=ac8c6295cab69bc474549c1c54eb313caedba826;hb=cd6cfe0f578c4f744ddc9a342243aff6b42f8027;hp=e8f1de780597eb44d4e0b3c6a4356e9bd89f5ba6;hpb=1790a6c95a86c15a92fe3f5ec4af76c76a26f38a;p=pdclib.old diff --git a/functions/uchar/c16rtomb.c b/functions/uchar/c16rtomb.c index e8f1de7..ac8c629 100644 --- a/functions/uchar/c16rtomb.c +++ b/functions/uchar/c16rtomb.c @@ -24,6 +24,8 @@ size_t c16rtomb_l( ) { const char16_t *restrict psrc = &c16; + char buf[s ? 0 : MB_CUR_MAX]; + s = s ? s : buf; if(!l->_Codec->__c16stombs) { // Codec doesn't support direct conversion - translate via UCS-4 @@ -58,6 +60,7 @@ size_t c16rtomb_l( if((c16 & 0xFC00) == 0xDC00) { // Trailing surrogate char32_t c32 = (ps->_Surrogate & 0x3FF) << 10 | (c16 & 0x3FF); + ps->_Surrogate = 0; return c32rtomb_l(s, c32, ps, l); } else { // Not a trailing surrogate - encoding error