MCPcopy Create free account
hub / github.com/acl-dev/acl / win_iconv

Function win_iconv

lib_acl_cpp/src/stdlib/internal/win_iconv.cpp:801–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

799}
800
801static size_t
802win_iconv(iconv_t _cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
803{
804 rec_iconv_t *cd = (rec_iconv_t *)_cd;
805 ushort wbuf[MB_CHAR_MAX]; /* enough room for one character */
806 int insize;
807 int outsize;
808 int wsize;
809 DWORD mode;
810 uint wc;
811 compat_t *cp;
812 int i;
813
814 if (inbuf == NULL || *inbuf == NULL)
815 {
816 if (outbuf != NULL && *outbuf != NULL && cd->to.flush != NULL)
817 {
818 outsize = cd->to.flush(&cd->to, (uchar *)*outbuf,
819 (int) (*outbytesleft));
820 if (outsize == -1)
821 return (size_t)(-1);
822 *outbuf += outsize;
823 *outbytesleft -= outsize;
824 }
825 if (is_unicode(cd->from.codepage) && (cd->from.mode & UNICODE_MODE_SWAPPED))
826 cd->from.codepage ^= 1;
827 cd->from.mode = 0;
828 cd->to.mode = 0;
829 return 0;
830 }
831
832 while (*inbytesleft != 0)
833 {
834 mode = cd->from.mode;
835 wsize = MB_CHAR_MAX;
836
837 insize = cd->from.mbtowc(&cd->from, (const uchar *)*inbuf,
838 (int) (*inbytesleft), wbuf, &wsize);
839 if (insize == -1)
840 return (size_t)(-1);
841
842 if (is_unicode(cd->from.codepage) && !(cd->from.mode & UNICODE_MODE_BOM_DONE))
843 {
844 check_utf_bom(cd, wbuf, &wsize);
845 cd->from.mode |= UNICODE_MODE_BOM_DONE;
846 }
847
848 if (wsize == 0)
849 {
850 *inbuf += insize;
851 *inbytesleft -= insize;
852 continue;
853 }
854
855 if (cd->from.compat != NULL)
856 {
857 wc = utf16_to_ucs4(wbuf);
858 cp = cd->from.compat;

Callers

nothing calls this directly

Calls 5

is_unicodeFunction · 0.85
check_utf_bomFunction · 0.85
utf16_to_ucs4Function · 0.85
ucs4_to_utf16Function · 0.85
flushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…