src/lib/CDRParser.cpp | 15 +++++++++------ src/lib/libcdr_utils.cpp | 9 +++++++++ src/lib/libcdr_utils.h | 1 + 3 files changed, 19 insertions(+), 6 deletions(-)
New commits: commit e2b0c8a788ec124a58a63ddc56d77fa317624bf5 Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Mon Mar 22 16:40:12 2021 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Mon Mar 22 16:40:12 2021 +0100 use boost spirit in unicode when appropriate Change-Id: I9c97f3010ba7d4ec38dde0825e61fca6c7bce62e diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 045a1b9..f9dba55 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -17,6 +17,9 @@ #ifndef BOOST_ALL_NO_LIB #define BOOST_ALL_NO_LIB 1 #endif +#ifndef BOOST_SPIRIT_UNICODE +#define BOOST_SPIRIT_UNICODE 1 +#endif #include <boost/algorithm/string.hpp> #include <boost/optional.hpp> #include <boost/property_tree/json_parser.hpp> @@ -147,14 +150,14 @@ static int parseColourString(const char *colourString, libcdr::CDRColor &colour, bRes = phrase_parse(it, end, // Begin grammar ( - (cmodel | omit[+iso8859_1::alnum]) >> lit(',') - >> (cpalette | omit[+iso8859_1::alnum]) >> lit(',') + (cmodel | omit[+unicode::alnum]) >> lit(',') + >> (cpalette | omit[+unicode::alnum]) >> lit(',') >> *(uint_ >> lit(',')) - >> omit[(repeat(8)[iso8859_1::xdigit] >> '-' >> repeat(3)[repeat(4)[iso8859_1::xdigit] >> '-'] >> repeat(12)[iso8859_1::xdigit])] - >> -(lit(',') >> *iso8859_1::char_) + >> omit[(repeat(8)[unicode::xdigit] >> '-' >> repeat(3)[repeat(4)[unicode::xdigit] >> '-'] >> repeat(12)[unicode::xdigit])] + >> -(lit(',') >> *unicode::char_) ), // End grammar - iso8859_1::space, + unicode::space, colourModel, colourPalette, val, rest) && it == end; } commit 9bbf5b653324ea567269b5ac18e09853dff4a0cd Author: Fridrich Štrba <fridrich.st...@bluewin.ch> AuthorDate: Mon Mar 22 16:25:38 2021 +0100 Commit: Fridrich Štrba <fridrich.st...@bluewin.ch> CommitDate: Mon Mar 22 16:25:38 2021 +0100 Read the json as utf-8 for versions 17+ Change-Id: I4fa754ba03be06594e421de1d03be25aec0e5c1e diff --git a/src/lib/CDRParser.cpp b/src/lib/CDRParser.cpp index 62bdf0d..045a1b9 100644 --- a/src/lib/CDRParser.cpp +++ b/src/lib/CDRParser.cpp @@ -3055,7 +3055,7 @@ void libcdr::CDRParser::_readX6StyleString(librevenge::RVNGInputStream *input, u memcpy(&styleBuffer[0], tmpBuffer, numBytesRead); librevenge::RVNGString styleString; if (m_version >= 1700) - libcdr::appendCharacters(styleString, styleBuffer, 0); + libcdr::appendUTF8Characters(styleString, styleBuffer); else libcdr::appendCharacters(styleString, styleBuffer); CDR_DEBUG_MSG(("CDRParser::_readX6StyleString - styleString = \"%s\"\n", styleString.cstr())); diff --git a/src/lib/libcdr_utils.cpp b/src/lib/libcdr_utils.cpp index 250f0a0..c900b0a 100644 --- a/src/lib/libcdr_utils.cpp +++ b/src/lib/libcdr_utils.cpp @@ -462,6 +462,15 @@ void libcdr::appendCharacters(librevenge::RVNGString &text, std::vector<unsigned ucnv_close(conv); } +void libcdr::appendUTF8Characters(librevenge::RVNGString &text, std::vector<unsigned char> characters) +{ + if (characters.empty()) + return; + + for (std::vector<unsigned char>::const_iterator iter = characters.begin(); iter != characters.end(); ++iter) + text.append((char)*iter); +} + #ifdef DEBUG void libcdr::debugPrint(const char *const format, ...) diff --git a/src/lib/libcdr_utils.h b/src/lib/libcdr_utils.h index a4472fc..52871e3 100644 --- a/src/lib/libcdr_utils.h +++ b/src/lib/libcdr_utils.h @@ -91,6 +91,7 @@ void writeU16(librevenge::RVNGBinaryData &buffer, const int value); void writeU32(librevenge::RVNGBinaryData &buffer, const int value); void appendCharacters(librevenge::RVNGString &text, std::vector<unsigned char> characters, unsigned short charset); void appendCharacters(librevenge::RVNGString &text, std::vector<unsigned char> characters); +void appendUTF8Characters(librevenge::RVNGString &text, std::vector<unsigned char> characters); #ifdef DEBUG const char *toFourCC(unsigned value, bool bigEndian=false); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits