Re: Chinese Characters
Re: Chinese Characters
- Subject: Re: Chinese Characters
- From: "Mark J. Reed" <email@hidden>
- Date: Thu, 6 Aug 2009 08:08:51 -0400
On Thu, Aug 6, 2009 at 6:14 AM, Mark J. Reed<email@hidden> wrote:
> OTOH, given how slow the data load is, an external program that did
> the whole thing is another option - even if said program had to reread
> Blocks.txt every time it's invoked to identify a character. The
> per-character time might be slower, but you'd lose that whole-second
> startup delay.
Tested this concept out with this little Perl script:
#!/usr/bin/perl
use utf8;
use encoding qw(utf8);
die "Usage: $0 character\n" unless @ARGV == 1;
my $value = ord(shift);
open(my $fh, "</System/Library/Perl/5.8.8/unicore/Blocks.txt") or die
"$0: can't open block data file: $!\n";
while (<$fh>)
{
next unless /^[^# ]/;
my ($start, $end, $desc) = /(.*?)\.\.(.*?); (.*)/;
if ($value >= hex($start) && $value <= hex($end))
{
print "$desc\n";
exit 0;
}
}
exit 1;
and this handler:
on findBlock(someChar)
do shell script "perl /Users/mreed/findBlock.pl " & someChar
end findBlock
That takes 0.035 seconds per iteration on my machine, which seems to
be a little slower than yours - the dc(1) version takes about 5
seconds for the data load, while the native AS version takes 2 (about
0.04 sec per lookup thereafter).
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden