X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=internals%2F_PDCLIB_encoding.h;h=7d893c2d55196f39ab8e7187c5454bb292033f5c;hb=be738e08ec9ba2498d81153bee1de9b8af7e764c;hp=4d17123edb1dc20f64c9fc9e42b9ef3b51ac97f4;hpb=68530b0da9e164ca1f36374be11b03f2f6cd0c9f;p=pdclib diff --git a/internals/_PDCLIB_encoding.h b/internals/_PDCLIB_encoding.h index 4d17123..7d893c2 100644 --- a/internals/_PDCLIB_encoding.h +++ b/internals/_PDCLIB_encoding.h @@ -6,6 +6,7 @@ #ifndef __PDCLIB_ENCODING_H #define __PDCLIB_ENCODING_H __PDCLIB_ENCODING_H + #include /* Must be cauued with bufsize >= 1, in != NULL, out != NULL, ps != NULL @@ -75,18 +76,18 @@ static inline _PDCLIB_size_t _PDCLIB_c32rtoc16( return 1; } else { // Supplementary plane character - *out = 0xD800 | (*in & 0x3FF); + *out = 0xD800 | (*in >> 10); if(bufsize >= 2) { - out[1] = 0xDC00 | (*in >> 10); + out[1] = 0xDC00 | (*in & 0x3FF); return 2; } else { - ps->_Surrogate = 0xDC00 | (*in >> 10); + ps->_Surrogate = 0xDC00 | (*in & 0x3FF); return 1; } } } -struct _PDCLIB_charcodec { +struct _PDCLIB_charcodec_t { /* Reads at most *_P_insz code units from *_P_inbuf and writes the result * into *_P_outbuf, writing at most *_P_outsz code units. Updates * *_P_outbuf, *_P_outsz, *_P_inbuf, *_P_outsz with the resulting state @@ -99,6 +100,9 @@ struct _PDCLIB_charcodec { * encountered), else return false. */ + /* mbsinit. Mandatory. */ + _PDCLIB_bool (*__mbsinit)(const _PDCLIB_mbstate_t *_P_ps); + /* UCS-4 variants. Mandatory. */ _PDCLIB_bool (*__mbstoc32s)( @@ -189,10 +193,14 @@ _PDCLIB_locale_t _PDCLIB_restrict l); #if _PDCLIB_WCHAR_ENCODING == _PDCLIB_WCHAR_ENCODING_UTF16 #define _PDCLIB_mbrtocwc_l mbrtoc16_l + #define _PDCLIB_mbrtocwc mbrtoc16 #define _PDCLIB_cwcrtomb_l c16rtomb_l + #define _PDCLIB_cwcrtomb c16rtomb #elif _PDCLIB_WCHAR_ENCODING == _PDCLIB_WCHAR_ENCODING_UCS4 #define _PDCLIB_mbrtocwc_l mbrtoc32_l + #define _PDCLIB_mbrtocwc mbrtoc32 #define _PDCLIB_cwcrtomb_l c32rtomb_l + #define _PDCLIB_cwcrtomb c32rtomb #else #error _PDCLIB_WCHAR_ENCODING not defined correctly #error Define to one of _PDCLIB_WCHAR_ENCODING_UCS4 or _PDCLIB_WCHAR_ENCODING_UTF16