--- a/src/JavaPropertiesEscapingProcessor.h Sat Dec 12 19:52:38 2020 +0100
+++ b/src/JavaPropertiesEscapingProcessor.h Sat Dec 12 23:09:50 2020 +0100
@@ -17,6 +17,7 @@
#pragma once
#include <sstream>
+#include <iomanip>
#include <relpipe/common/type/typedefs.h>
@@ -34,10 +35,12 @@
relpipe::common::type::StringX escape(const relpipe::common::type::StringX& s, const TextType textType, const QuotingType quotingType) override {
std::wstringstream result;
+ bool isKey = textType == TextType::EntryKey || textType == TextType::EntrySubKey;
+
for (auto ch : s) {
if (ch == L'\\') result.put(ESC).put(ESC);
else if (ch == L'\n') result.put(ESC).put(L'n');
- // TODO: escape unicode
+ else if (ch >= 127 || ((ch == L'=' || ch == L':') && isKey)) result << L"\\u" << std::hex << std::setfill(L'0') << std::setw(4) << (int) ch;
else result.put(ch);
}