utils: cleanup whitespace

This commit is contained in:
Dirk-Jan C. Binnema 2021-03-16 17:07:39 +02:00
parent 725826231f
commit 15aca5e396
3 changed files with 285 additions and 269 deletions

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2017 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2017-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
@ -147,6 +147,9 @@ Mu::utf8_clean (const std::string& dirty)
clean.erase (clean.find_last_not_of(" ") + 1); // remove trailing space
return clean;
}
std::string
Mu::remove_ctrl (const std::string& str)
{
@ -165,6 +168,7 @@ Mu::remove_ctrl (const std::string& str)
return result;
}
std::vector<std::string>
Mu::split (const std::string& str, const std::string& sepa)
{

View File

@ -1,5 +1,5 @@
/*
** Copyright (C) 2020 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** Copyright (C) 2020-2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public License
@ -43,8 +43,6 @@ using StringVec = std::vector<std::string>;
std::string utf8_flatten (const char *str);
inline std::string utf8_flatten (const std::string& s) { return utf8_flatten(s.c_str()); }
/**
* Replace all control characters with spaces, and remove leading and trailing space.
*
@ -55,6 +53,19 @@ inline std::string utf8_flatten (const std::string& s) { return utf8_flatten(s.c
std::string utf8_clean (const std::string& dirty);
/**
* Remove ctrl characters, replacing them with ' '; subsequent
* ctrl characters are replaced by a single ' '
*
* @param str a string
*
* @return the string without control characters
*/
std::string remove_ctrl (const std::string& str);
/**
* Split a string in parts
*

View File

@ -214,6 +214,7 @@ main (int argc, char *argv[])
g_test_add_func ("/utils/date-ymwdhMs", test_date_ymwdhMs);
g_test_add_func ("/utils/size", test_size);
g_test_add_func ("/utils/flatten", test_flatten);
g_test_add_func ("/utils/remove-ctrl", test_remove_ctrl);
g_test_add_func ("/utils/clean", test_clean);
g_test_add_func ("/utils/format", test_format);
g_test_add_func ("/utils/define-bitmap", test_define_bitmap);