mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 17:48:38 +00:00
fix for latest git of poppler : do not use utf.h
This commit is contained in:
parent
d2374b16c5
commit
41d4cb9a9c
|
@ -18,8 +18,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <UTF8.h>
|
|
||||||
|
|
||||||
#ifndef nullptr
|
#ifndef nullptr
|
||||||
#define nullptr (NULL)
|
#define nullptr (NULL)
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,16 +36,6 @@ extern const std::map<std::string, std::string> GB_ENCODED_FONT_NAME_MAP;
|
||||||
// value: (prefix string, suffix string)
|
// value: (prefix string, suffix string)
|
||||||
extern const std::map<std::pair<std::string, bool>, std::pair<std::string, std::string> > EMBED_STRING_MAP;
|
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 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 _equal(double x, double y) { return std::abs(x-y) < EPS; }
|
||||||
static inline bool _is_positive(double x) { return x > EPS; }
|
static inline bool _is_positive(double x) { return x > EPS; }
|
||||||
|
|
39
src/util.cc
39
src/util.cc
|
@ -123,6 +123,45 @@ Unicode check_unicode(Unicode * u, int len, CharCode code, GfxFont * font)
|
||||||
return unicode_from_font(code, 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)
|
void outputUnicodes(ostream & out, const Unicode * u, int uLen)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < uLen; ++i)
|
for(int i = 0; i < uLen; ++i)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user