MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / escapeDesktopValue

Function escapeDesktopValue

app/src/Misc/ShortcutGenerator_Linux.cpp:32–57  ·  view source on GitHub ↗

* @brief Escapes control characters per the Desktop Entry spec. */

Source from the content-addressed store, hash-verified

30 * @brief Escapes control characters per the Desktop Entry spec.
31 */
32static QString escapeDesktopValue(const QString& value)
33{
34 QString out;
35 out.reserve(value.size());
36 for (const QChar ch : value) {
37 switch (ch.unicode()) {
38 case u'\\':
39 out += QStringLiteral("\\\\");
40 break;
41 case u'\n':
42 out += QStringLiteral("\\n");
43 break;
44 case u'\r':
45 out += QStringLiteral("\\r");
46 break;
47 case u'\t':
48 out += QStringLiteral("\\t");
49 break;
50 default:
51 out += ch;
52 break;
53 }
54 }
55
56 return out;
57}
58
59/**
60 * @brief Doubles literal `%` so the launcher does not treat them as field codes.

Callers 1

writeLinuxDesktopMethod · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected