cpp/poppler-private.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
New commits: commit aaff2ee913fcc37cf35384e198587fe848d2cdf3 Author: Albert Astals Cid <[email protected]> Date: Thu Mar 28 14:29:13 2019 +0100 cpp: Support UTF16-LE strings They are not supported in the spec but Adobe supports them and there's files outthere with these kind of strings, so we're supporting them diff --git a/cpp/poppler-private.cpp b/cpp/poppler-private.cpp index d1a05310..a532b350 100644 --- a/cpp/poppler-private.cpp +++ b/cpp/poppler-private.cpp @@ -3,7 +3,7 @@ * Copyright (C) 2013 Adrian Johnson <[email protected]> * Copyright (C) 2014, Hans-Peter Deifel <[email protected]> * Copyright (C) 2016 Jakub Alba <[email protected]> - * Copyright (C) 2017, 2018 Albert Astals Cid <[email protected]> + * Copyright (C) 2017-2019 Albert Astals Cid <[email protected]> * Copyright (C) 2018 Suzuki Toshiya <[email protected]> * * This program is free software; you can redistribute it and/or modify @@ -62,12 +62,9 @@ ustring detail::unicode_GooString_to_ustring(const GooString *str) const char *data = str->c_str(); const int len = str->getLength(); - int i = 0; - bool is_unicode = false; - if ((data[0] & 0xff) == 0xfe && (len > 1 && (data[1] & 0xff) == 0xff)) { - is_unicode = true; - i = 2; - } + const bool is_unicodeLE = str->hasUnicodeMarkerLE(); + const bool is_unicode = str->hasUnicodeMarker() || is_unicodeLE; + int i = is_unicode ? 2 : 0; ustring::size_type ret_len = len - i; if (is_unicode) { ret_len >>= 1; @@ -77,7 +74,8 @@ ustring detail::unicode_GooString_to_ustring(const GooString *str) ustring::value_type u; if (is_unicode) { while (i < len) { - u = ((data[i] & 0xff) << 8) | (data[i + 1] & 0xff); + u = is_unicodeLE ? ((data[i + 1] & 0xff) << 8) | (data[i] & 0xff) + : ((data[i] & 0xff) << 8) | (data[i + 1] & 0xff); i += 2; ret[ret_index++] = u; } _______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
