X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=opt%2Fbasecodecs%2F_PDCLIB_utf8.c;h=22fa808c963fa33b4a1bfbd71565bfc141c5bc84;hb=c83b63d8752d32b5fe82aa2b1c3b570eef531436;hp=b0d3413e696d7489f3d6b5b2f7f6968a3f8da240;hpb=2df4e196c1bd79970974ccbeec1d6b392d2c71ab;p=pdclib diff --git a/opt/basecodecs/_PDCLIB_utf8.c b/opt/basecodecs/_PDCLIB_utf8.c index b0d3413..22fa808 100644 --- a/opt/basecodecs/_PDCLIB_utf8.c +++ b/opt/basecodecs/_PDCLIB_utf8.c @@ -17,6 +17,9 @@ * _St32[1] is the character accumulated so far */ +static bool utf8_mbsinit( const mbstate_t *p_s ) +{ return p_s->_StUC[0] == 0; } + enum { DecStart = 0, @@ -52,6 +55,7 @@ end_conversion: \ _PDCLIB_UNDEFINED(accum); \ state = DecStart; \ } while(0) + #define CHECK_CONTINUATION \ do { if((c & 0xC0) != 0x80) return false; } while(0) @@ -228,9 +232,11 @@ static bool c32toutf8( END_CONVERSION; } -_PDCLIB_charcodec_t _PDCLIB_utf8_codec = { +const struct _PDCLIB_charcodec _PDCLIB_utf8_codec = { + .__mbsinit = utf8_mbsinit, .__mbstoc32s = utf8toc32, .__c32stombs = c32toutf8, + .__mb_max = 4, }; #endif