1
//========================================================================
5
// Mapping from Unicode to an encoding.
7
// Copyright 2001-2003 Glyph & Cog, LLC
9
//========================================================================
14
#ifdef USE_GCC_PRAGMAS
18
#include "poppler-config.h"
19
#include "goo/gtypes.h"
20
#include "CharTypes.h"
23
#include "goo/GooMutex.h"
28
//------------------------------------------------------------------------
31
unicodeMapUser, // read from a file
32
unicodeMapResident, // static list of ranges
33
unicodeMapFunc // function pointer
36
typedef int (*UnicodeMapFunc)(Unicode u, char *buf, int bufSize);
38
struct UnicodeMapRange {
39
Unicode start, end; // range of Unicode chars
40
Guint code, nBytes; // first output code
45
//------------------------------------------------------------------------
50
// Create the UnicodeMap specified by <encodingName>. Sets the
51
// initial reference count to 1. Returns NULL on failure.
52
static UnicodeMap *parse(GooString *encodingNameA);
54
// Create a resident UnicodeMap.
55
UnicodeMap(char *encodingNameA, GBool unicodeOutA,
56
UnicodeMapRange *rangesA, int lenA);
58
// Create a resident UnicodeMap that uses a function instead of a
60
UnicodeMap(char *encodingNameA, GBool unicodeOutA,
61
UnicodeMapFunc funcA);
68
GooString *getEncodingName() { return encodingName; }
70
GBool isUnicode() { return unicodeOut; }
72
// Return true if this UnicodeMap matches the specified
74
GBool match(GooString *encodingNameA);
76
// Map Unicode to the target encoding. Fills in <buf> with the
77
// output and returns the number of bytes used. Output will be
78
// truncated at <bufSize> bytes. No string terminator is written.
79
// Returns 0 if no mapping is found.
80
int mapUnicode(Unicode u, char *buf, int bufSize);
84
UnicodeMap(GooString *encodingNameA);
86
GooString *encodingName;
90
UnicodeMapRange *ranges; // (user, resident)
91
UnicodeMapFunc func; // (func)
93
int len; // (user, resident)
94
UnicodeMapExt *eMaps; // (user)
95
int eMapsLen; // (user)
102
//------------------------------------------------------------------------
104
#define unicodeMapCacheSize 4
106
class UnicodeMapCache {
112
// Get the UnicodeMap for <encodingName>. Increments its reference
113
// count; there will be one reference for the cache plus one for the
114
// caller of this function. Returns NULL on failure.
115
UnicodeMap *getUnicodeMap(GooString *encodingName);
119
UnicodeMap *cache[unicodeMapCacheSize];