--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/XercesStringConvertor.h Fri Jan 11 16:13:21 2019 +0100
@@ -0,0 +1,57 @@
+/**
+ * Relational pipes
+ * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <string>
+#include <codecvt>
+
+#include <xercesc/util/XMLString.hpp>
+
+#include <relpipe/writer/typedefs.h>
+
+namespace relpipe {
+namespace in {
+namespace xml {
+
+using namespace std;
+using namespace xercesc;
+using namespace relpipe::writer;
+
+class XercesStringConvertor {
+private:
+ wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
+
+public:
+
+ string_t toString(const XMLCh * const chars) {
+ // XMLCh = char16_t
+ // „All XML data is handled within Xerces-C++ as strings of XMLCh characters. Regardless of the size of the type chosen, the data stored in variables of type XMLCh will always be utf-16 encoded values.“
+ // see https://xerces.apache.org/xerces-c/program-others-3.html
+ // other solution (depends on boost): https://flylib.com/books/en/2.131.1/working_with_xerces_strings.html
+
+ // TODO: review this text conversion and test on various platforms
+ char* x = XMLString::transcode(chars);
+ string s = string(x);
+ XMLString::release(&x);
+ return convertor.from_bytes(s);
+ }
+};
+
+}
+}
+}