Skip to content

Commit

Permalink
attempted fix for #55
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Mar 29, 2024
1 parent e94937f commit 0911bfb
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/folia_utils.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,24 @@ namespace folia {
UChar32 shy = 0x00ad; // soft hyphen
bool is_space = false;
for ( int i=0; i < input.length(); ++i ){
if ( input[i] != shy
&& ( u_isspace( input[i] )
|| u_iscntrl( input[i] ) ) ){
if ( is_space ){
// already a space added, skip this character
if ( input[i] != shy ){
if ( u_isspace( input[i] ) ){
if ( is_space ){
// already a space added, skip this one
continue;
}
is_space = true;
result += " ";
continue;
}
else if ( u_iscntrl( input[i] ) ){
// ignore
continue;
}
is_space = true;
result += " ";
}
else {
// normal character, keep it
is_space = false;
result += input[i];
}
// normal character, keep it
is_space = false;
result += input[i];
}
result.trim(); // remove leading and trailing whitespace;
return result;
Expand Down

0 comments on commit 0911bfb

Please sign in to comment.