develooper Front page | perl.perl5.porters | Postings from July 2003

Re: [] setting locale in Tk::Text wiget?

Nick Ing-Simmons
July 30, 2003 11:43
Re: [] setting locale in Tk::Text wiget?
Message ID:
Slaven Rezic <> writes:
>Here's a problem with the Tk::Text::search method and use locale. It
>seems to me that Lang_RegExpCompile should set the PMf_LOCALE flag if
>"use locale" is in effect, but AFAIK the PL_hints information is not
>available at runtime. Would it be possible to use qr{...} instead and
>change some code in tkGlue.c so Regexp objects are allowed?

Allowing passing in of qr// seems like a good idea.
It is far from clear to me how locale and Unicode interact.

>	Slaven
>Slaven Rezic -
>    tkrevdiff - graphical display of diffs between revisions (RCS, CVS or SVN)
>------- Start of forwarded message -------
>From: "Steve Schulze" <>
>Subject: setting locale in Tk::Text wiget?
>Date: Fri, 25 Jul 2003 21:47:43 -0400
>Message-ID: <>
>I've been playing around with the text wigets and have stumbled across
>somthing I just can't figure out. Is there some sort of undocumented method
>to force Tk Text wigets to use the locale settings when doing regexp
>searches? No matter what I do I can't seem to get the search method to use
>the locale setting. I haven't been able to find anything in the FAQs or DOCs
>about it. Feel free to give me a dope slap if you can point to it in the
>perl FAQ.
>tiny demo script: (notice the accented character in $var)
>use strict;
>use locale;
>use Tk;
>use Tk::Text;
>my $top = MainWindow->new();
>my $frame = $top->Frame->pack;
>my $textbox = $frame->Text->pack;
>my $var = "ĂȘtes";
>print (($var=~/\w\w\w\w/) ? "regex match\n" : "regex fail\n");
>print (($textbox->search('-regexp','--','\w\w\w\w','1.0','end')) ? "text
>wiget regex match\n" : "text wiget regex fail\n");
>I would expect this to print:
>regex match
>text wiget regex match
>but instead I get:
>regex match
>text wiget regex fail
>If you change the text regexp expression to '\W\w\w\w' it will match.
>If you comment out  "use locale;"  then both fail, as expected.
>How do you make the text regexp search use the locale setting? It certainly
>seems like it should be within its scope.
>(ActiveState on win 98 and win 2k)
>------- End of forwarded message ------- Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About