From 672b9afb9bb05a67bbcd8664ba268521ea728ca6 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 13 Nov 2018 21:49:56 +0100 Subject: 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. --- source/fitz/encodings.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 source/fitz/encodings.c (limited to 'source/fitz/encodings.c') 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 +#include + +#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) -- cgit v1.2.3