mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Function: visible
- Added helper function to render control characters visible. This may be replaced by JSON::encode.
This commit is contained in:
parent
ac811c6930
commit
7e5b43bb9d
2 changed files with 23 additions and 0 deletions
22
src/text.cpp
22
src/text.cpp
|
@ -682,6 +682,28 @@ bool isPunctuation (char c)
|
|||
return ispunct (c);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string visible (char input)
|
||||
{
|
||||
// Sanitize 'message'.
|
||||
char stringized[2] = {0};
|
||||
stringized[0] = input;
|
||||
|
||||
std::string sanitized = stringized;
|
||||
switch (input)
|
||||
{
|
||||
case ' ': sanitized = "\\s"; break;
|
||||
case '\r': sanitized = "\\r"; break;
|
||||
case '\n': sanitized = "\\n"; break;
|
||||
case '\f': sanitized = "\\f"; break;
|
||||
case '\t': sanitized = "\\t"; break;
|
||||
case '\v': sanitized = "\\v"; break;
|
||||
default: sanitized = input; break;
|
||||
}
|
||||
|
||||
return sanitized;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool compare (
|
||||
const std::string& left,
|
||||
|
|
|
@ -63,6 +63,7 @@ bool isWordStart (const std::string&, std::string::size_type);
|
|||
bool isWordEnd (const std::string&, std::string::size_type);
|
||||
bool isTokenEnd (const std::string&, std::string::size_type);
|
||||
bool isPunctuation (char);
|
||||
std::string visible (char);
|
||||
bool compare (const std::string&, const std::string&, bool sensitive = true);
|
||||
bool closeEnough (const std::string&, const std::string&, unsigned int minLength = 0);
|
||||
std::string::size_type find (const std::string&, const std::string&, bool sensitive = true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue