summaryrefslogtreecommitdiff
path: root/source/fitz/encodings.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-11-13 21:49:56 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-11-13 23:45:37 +0100
commit672b9afb9bb05a67bbcd8664ba268521ea728ca6 (patch)
tree24699741d5cf8d71ac8f5d000722e82388a97bc7 /source/fitz/encodings.c
parenta06709ac88453bbfeff46ddaa62492172183b1a7 (diff)
downloadmupdf-672b9afb9bb05a67bbcd8664ba268521ea728ca6.tar.xz
Add more encoding tables.
Add tables for Windows-1250, Windows-1251, and ISO-8859-1. Also add unicode_from_encoding tables. Move encodings from PDF namespace to Fitz.
Diffstat (limited to 'source/fitz/encodings.c')
-rw-r--r--source/fitz/encodings.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/fitz/encodings.c b/source/fitz/encodings.c
new file mode 100644
index 00000000..004ae90f
--- /dev/null
+++ b/source/fitz/encodings.c
@@ -0,0 +1,33 @@
+#include "mupdf/fitz.h"
+#include "mupdf/pdf.h"
+
+#include "encodings.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+#define FROM_UNICODE(ENC) \
+{ \
+ int l = 0; \
+ int r = nelem(ENC##_from_unicode) - 1; \
+ if (u < 128) \
+ return u; \
+ while (l <= r) \
+ { \
+ int m = (l + r) >> 1; \
+ if (u < ENC##_from_unicode[m].u) \
+ r = m - 1; \
+ else if (u > ENC##_from_unicode[m].u) \
+ l = m + 1; \
+ else \
+ return ENC##_from_unicode[m].c; \
+ } \
+ return -1; \
+}
+
+int fz_iso8859_1_from_unicode(int u) FROM_UNICODE(iso8859_1)
+int fz_iso8859_7_from_unicode(int u) FROM_UNICODE(iso8859_7)
+int fz_koi8u_from_unicode(int u) FROM_UNICODE(koi8u)
+int fz_windows_1250_from_unicode(int u) FROM_UNICODE(windows_1250)
+int fz_windows_1251_from_unicode(int u) FROM_UNICODE(windows_1251)
+int fz_windows_1252_from_unicode(int u) FROM_UNICODE(windows_1252)