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

Re: [comp.lang.perl.tk] setting locale in Tk::Text wiget?

From:
Nick Ing-Simmons
Date:
July 30, 2003 11:43
Subject:
Re: [comp.lang.perl.tk] setting locale in Tk::Text wiget?
Message ID:
20030730184256.2393.1@llama.ni-s.u-net.com
Slaven Rezic <slaven@rezic.de> 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.


>
>Regards,
>	Slaven
>
>-- 
>Slaven Rezic - slaven@rezic.de
>
>    tkrevdiff - graphical display of diffs between revisions (RCS, CVS or SVN)
>    http://ptktools.sourceforge.net/#tkrevdiff
>------- Start of forwarded message -------
>From: "Steve Schulze" <notmy@email.com>
>Newsgroups: comp.lang.perl.tk
>Subject: setting locale in Tk::Text wiget?
>Date: Fri, 25 Jul 2003 21:47:43 -0400
>Message-ID: <GTOdnYvch_AhQLyiXTWJjQ@comcast.com>
>
>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)
>
>#!/usr/bin/perl-w
>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");
>$textbox->insert('end',$var);
>print (($textbox->search('-regexp','--','\w\w\w\w','1.0','end')) ? "text
>wiget regex match\n" : "text wiget regex fail\n");
>MainLoop;
>
>
>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 5.8.0.805 on win 98 and win 2k)
>
>
>------- End of forwarded message -------




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About