# HG changeset patch # User František Kučera # Date 1607810990 -3600 # Node ID a823b1aaf1f629bdfc97712bdf37cbd186397768 # Parent bee7acb573300c2c2b068ea109ed95351e63e69a java .properties escaping diff -r bee7acb57330 -r a823b1aaf1f6 src/JavaPropertiesEscapingProcessor.h --- 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 +#include #include @@ -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); }