1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-03 08:38:39 +00:00

fix for latest git of poppler : do not use utf.h

This commit is contained in:
Lu Wang 2012-09-21 23:46:47 +08:00
parent d2374b16c5
commit 41d4cb9a9c
2 changed files with 39 additions and 12 deletions

View File

@ -18,8 +18,6 @@
#include <string>
#include <map>
#include <UTF8.h>
#ifndef nullptr
#define nullptr (NULL)
#endif
@ -38,16 +36,6 @@ extern const std::map<std::string, std::string> GB_ENCODED_FONT_NAME_MAP;
// value: (prefix string, suffix string)
extern const std::map<std::pair<std::string, bool>, std::pair<std::string, std::string> > EMBED_STRING_MAP;
// mute gcc warning of unused function
namespace
{
template <class T>
void _(){
auto _1 = &mapUCS2;
auto _2 = &mapUTF8;
}
}
static inline double _round(double x) { return (std::abs(x) > EPS) ? x : 0.0; }
static inline bool _equal(double x, double y) { return std::abs(x-y) < EPS; }
static inline bool _is_positive(double x) { return x > EPS; }

View File

@ -123,6 +123,45 @@ Unicode check_unicode(Unicode * u, int len, CharCode code, GfxFont * font)
return unicode_from_font(code, font);
}
/*
* Copied from UTF.h / UTF8.h in poppler
*/
static int mapUTF8(Unicode u, char *buf, int bufSize) {
if (u <= 0x0000007f) {
if (bufSize < 1) {
return 0;
}
buf[0] = (char)u;
return 1;
} else if (u <= 0x000007ff) {
if (bufSize < 2) {
return 0;
}
buf[0] = (char)(0xc0 + (u >> 6));
buf[1] = (char)(0x80 + (u & 0x3f));
return 2;
} else if (u <= 0x0000ffff) {
if (bufSize < 3) {
return 0;
}
buf[0] = (char)(0xe0 + (u >> 12));
buf[1] = (char)(0x80 + ((u >> 6) & 0x3f));
buf[2] = (char)(0x80 + (u & 0x3f));
return 3;
} else if (u <= 0x0010ffff) {
if (bufSize < 4) {
return 0;
}
buf[0] = (char)(0xf0 + (u >> 18));
buf[1] = (char)(0x80 + ((u >> 12) & 0x3f));
buf[2] = (char)(0x80 + ((u >> 6) & 0x3f));
buf[3] = (char)(0x80 + (u & 0x3f));
return 4;
} else {
return 0;
}
}
void outputUnicodes(ostream & out, const Unicode * u, int uLen)
{
for(int i = 0; i < uLen; ++i)