]> vaikene.ee Git - evaf/blobdiff - src/libs/Common/util.h
Added functions to convert unicode strings to/from escaped 7-bit character arrays.
[evaf] / src / libs / Common / util.h
index 4b5e4c9fd81ce62aa7778f8a233b11c5e157d116..de094b3e791d85ef6caec890a532f521709e1617 100644 (file)
@@ -76,6 +76,27 @@ inline bool isFalse(QString const & str)
 
 COMMON_EXPORT QVariant toVariant(QString const & value, QVariant const & defaultValue);
 
+/**
+ * Converts unicode strings to escaped 7-bit character arrays.
+ * @param str Unicode string
+ * @return Escaped 7-bit character array
+ *
+ * This function converts a unicode (or any) string to the escaped 7-bit character array. Characters that cannot
+ * be output directly as a printable 7-bit character are output as numeric character references. The result can be
+ * directly inserted into XML or HTML documents and later converted back with the eVaf::Common::fromEscapedString()
+ * function.
+ */
+COMMON_EXPORT QByteArray toEscapedString(QString const & str);
+
+/**
+ * Converts escaped 7-bit character arrays to unicode string.
+ * @param str Escaped 7-bit character array
+ * @return Unicode string
+ *
+ * This function converts an escaped 7-bit character array to a unicode string. Numeric character references and
+ * character entity references are expanded to actual unicode characters.
+ */
+COMMON_EXPORT QString fromEscapedString(QByteArray const & str);
 
 } // namespace eVaf::Common
 } // namespace eVaf