#8652 Import Surface: Fix ts-file import with properties on Linux (#8730)

The file had DOS line endings (\t\n) which where not properly trimmed on linux.

Fixes #8652.
This commit is contained in:
Kristian Bendiksen
2022-03-25 14:16:25 +01:00
committed by GitHub
parent 80234ca105
commit 86ea679871
4 changed files with 92 additions and 6 deletions

View File

@@ -23,15 +23,32 @@
#include <cctype>
#include <charconv>
const std::string WHITESPACE = " \n\r\t\f\v";
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::leftTrimString( const std::string& s )
{
size_t start = s.find_first_not_of( WHITESPACE );
return ( start == std::string::npos ) ? "" : s.substr( start );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::rightTrimString( const std::string& s )
{
size_t end = s.find_last_not_of( WHITESPACE );
return ( end == std::string::npos ) ? "" : s.substr( 0, end + 1 );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RiaStdStringTools::trimString( const std::string& s )
{
auto sCopy = s.substr( 0, s.find_last_not_of( ' ' ) + 1 );
sCopy = sCopy.substr( sCopy.find_first_not_of( ' ' ) );
return sCopy;
return rightTrimString( leftTrimString( s ) );
}
//--------------------------------------------------------------------------------------------------