Re: Unicode::Collate string replacements and whitespace

[email protected] (SADAHIRO Tomoyuki) Thu, 23 Sep 2010 00:46:04 +0900
Newsgroups perl.unicode
Message-ID <[email protected]>
Thank you for your bug report,

A workaround would be
    $myCollator->gsubst($str, "camelhorse", sub { "$_[0]" });
(removal of the space from the substring)

and a patch should be

 	if (@subWt && !$var && !$wt[0]) {
 	    push @{ $subWt[-1] }, \@wt if $to_be_pushed;
-	} else {
+	} elsif ($to_be_pushed) {
 	    push @subWt, [ \@wt ];
 	}
     }

Regards,
SADAHIRO Tomoyuki

> dear all,
> most probably I'm missing something quite obvious and very simple,
> but I am no expert with Perl and Unicode yet.
>  I'm making some string replacements with Unicode::Collate
> which generally works fine but for whitespace. I have the following
> simple code (adopted from the module documentation):
>  
> my $myCollator = Unicode::Collate->new( normalization => undef, level => 1 );
> my $str = "Camel donkey zebra camex{301}l CAMEL horse cAmEL...";
> $myCollator->gsubst($str, "camel horse", sub { "$_[0]" });
> print $str;

> this doesn't find the search string "camel horse" - if I search
> for "camel" the desired replacemts work ("camel").

> How can I get this working with whitespace in the search string?
> Thanks for any hints,
> Frank