Remove spaces from Source name

Replace space by underscore
This commit is contained in:
Bruno Herbelin
2021-12-25 00:41:24 +01:00
parent 0a27c14041
commit b885e70fed
3 changed files with 14 additions and 1 deletions

View File

@@ -104,6 +104,16 @@ std::string BaseToolkit::transliterate(const std::string &input)
}
std::string BaseToolkit::unspace(const std::string &input)
{
std::string output = input;
for(std::size_t i = 0; i < output.length(); ++i) {
if( isspace(output[i]) )
output[i] = '_';
}
return output;
}
std::string BaseToolkit::byte_to_string(long b)
{
double numbytes = static_cast<double>(b);

View File

@@ -16,6 +16,9 @@ std::string uniqueName(const std::string &basename, std::list<std::string> exist
// get a transliteration to Latin of any string
std::string transliterate(const std::string &input);
// replaces spaces by underscores in a string
std::string unspace(const std::string &input);
// get a string to display memory size with unit KB, MB, GB, TB
std::string byte_to_string(long b);

View File

@@ -347,7 +347,7 @@ Source::~Source()
void Source::setName (const std::string &name)
{
if (!name.empty())
name_ = BaseToolkit::transliterate(name);
name_ = BaseToolkit::unspace( BaseToolkit::transliterate(name) );
initials_[0] = std::toupper( name_.front(), std::locale("C") );
initials_[1] = std::toupper( name_.back(), std::locale("C") );