--- BUILD/xpdf-3.02-poppler/PDFCore.cc +++ BUILD/xpdf-3.02-poppler/PDFCore.cc @@ -13,6 +13,10 @@ #endif #include +#include +#include +#include +#include #include "GooString.h" #include "GooList.h" #include "GlobalParams.h" @@ -1602,15 +1606,33 @@ Unicode *u; int len, i; GBool ret; + iconv_t cd; + char *inptr, *outptr; + size_t insize, outsize; + size_t nchars; // convert to Unicode len = strlen(s); u = (Unicode *)gmallocn(len, sizeof(Unicode)); - for (i = 0; i < len; ++i) { - u[i] = (Unicode)(s[i] & 0xff); + + nchars = len; + if (len > 0) { +#if __BYTE_ORDER == __LITTLE_ENDIAN + cd = iconv_open ("UCS-4LE",nl_langinfo (CODESET)); +#else + cd = iconv_open ("UCS-4BE",nl_langinfo (CODESET)); +#endif + inptr = s; + outptr = (char *) u; + insize = len; + outsize = (len * sizeof(Unicode)); + memset (u, 0, (len * sizeof(Unicode))); + iconv (cd, &inptr, &insize, &outptr, &outsize); + nchars = len-outsize/4; + iconv_close (cd); } - ret = findU(u, len, caseSensitive, next, backward, onePageOnly); + ret = findU(u, nchars, caseSensitive, next, backward, onePageOnly); gfree(u); return ret;