X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=internals%2F_PDCLIB_encoding.h;h=cec3089aa8e3ad01460485990255c5b950b33b3d;hb=2760171eacbcdecc1fb28a76323aa9ceb06da921;hp=4d17123edb1dc20f64c9fc9e42b9ef3b51ac97f4;hpb=1d4e8006a01beb9e40b23fb8b58283fcc46c0757;p=pdclib.old diff --git a/internals/_PDCLIB_encoding.h b/internals/_PDCLIB_encoding.h index 4d17123..cec3089 100644 --- a/internals/_PDCLIB_encoding.h +++ b/internals/_PDCLIB_encoding.h @@ -75,12 +75,12 @@ 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; } } @@ -189,10 +189,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