diff options
author | Martin Kretzschmar <martink@gnome.org> | 2005-06-20 18:45:41 +0000 |
---|---|---|
committer | Martin Kretzschmar <martink@gnome.org> | 2005-06-20 18:45:41 +0000 |
commit | 9023891f314ac37811b5c973be2e36b6de353cf2 (patch) | |
tree | 29b3ad2a2e50d01cf7a11b2b330779716a10faea | |
parent | bbf2fe757f0fd08d0e90e3810709ab7152c779c0 (diff) |
(info_dict_get_string): convert from PDFDocEncoding to UTF-8.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | glib/poppler-document.cc | 16 |
2 files changed, 20 insertions, 1 deletions
@@ -1,3 +1,8 @@ +2005-06-20 Martin Kretzschmar <martink@gnome.org> + + * glib/poppler-document.cc (info_dict_get_string): convert + from PDFDocEncoding to UTF-8. + 2005-06-20 Kristian Høgsberg <krh@redhat.com> * glib/poppler-page.cc: diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index a20acadf..165ec410 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -27,6 +27,7 @@ #include <SplashOutputDev.h> #include <Stream.h> #include <FontInfo.h> +#include <PDFDocEncoding.h> #include "poppler.h" #include "poppler-private.h" @@ -219,7 +220,20 @@ info_dict_get_string (Dict *info_dict, const gchar *key, GValue *value) goo_value->getLength () - 2, "UTF-8", "UTF-16BE", NULL, NULL, NULL); } else { - result = g_strndup (goo_value->getCString (), goo_value->getLength ()); + int len; + gunichar *ucs4_temp; + int i; + + len = goo_value->getLength (); + ucs4_temp = g_new (gunichar, len + 1); + for (i = 0; i < len; ++i) { + ucs4_temp[i] = pdfDocEncoding[(unsigned char)goo_value->getChar(i)]; + } + ucs4_temp[i] = 0; + + result = g_ucs4_to_utf8 (ucs4_temp, -1, NULL, NULL, NULL); + + g_free (ucs4_temp); } obj.free (); |