• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Chinese Characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Chinese Characters
      • From: Simon Topliss <email@hidden>
References: 
 >Chinese Characters (From: Simon Topliss <email@hidden>)
 >Re: Chinese Characters (From: Philip Aker <email@hidden>)
 >Re: Chinese Characters (From: Simon Topliss <email@hidden>)
 >Re: Chinese Characters (From: "Mark J. Reed" <email@hidden>)
 >Re: Chinese Characters (From: Simon Topliss <email@hidden>)
 >Re: Chinese Characters (From: Simon Topliss <email@hidden>)
 >Re: Chinese Characters (From: "Mark J. Reed" <email@hidden>)

  • Prev by Date: Re: Chinese Characters
  • Next by Date: Re: Chinese Characters
  • Previous by thread: Re: Chinese Characters
  • Next by thread: Re: Chinese Characters
  • Index(es):
    • Date
    • Thread