diff --git a/src/output.cpp b/src/output.cpp index fed3ddc345241..1926e6f156f53 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -1516,14 +1516,15 @@ std::string trim_trailing_punctuations( const std::string_view s ) } ); } -std::string remove_punctuations( const std::string_view s ) +std::string remove_punctuations( const std::string &s ) { - std::string result; - std::remove_copy_if( s.begin(), s.end(), std::back_inserter( result ), - []( unsigned char ch ) { - return std::ispunct( ch ) && ch != '_'; + std::wstring ws = utf8_to_wstr( s ); + std::wstring result; + std::remove_copy_if( ws.begin(), ws.end(), std::back_inserter( result ), + []( wchar_t ch ) { + return std::iswpunct( ch ) && ch != '_'; } ); - return result; + return wstr_to_utf8( result ); } using char_t = std::string::value_type; diff --git a/src/output.h b/src/output.h index 26cd92fbddc33..c2226daca7e4b 100644 --- a/src/output.h +++ b/src/output.h @@ -626,7 +626,7 @@ std::string trim( std::string_view s ); // Removes trailing periods and exclamation marks. std::string trim_trailing_punctuations( std::string_view s ); // Removes all punctuation except underscore. -std::string remove_punctuations( std::string_view s ); +std::string remove_punctuations( const std::string &s ); // Converts the string to upper case. std::string to_upper_case( const std::string &s );