• 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: Producing Unicode-only characters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Producing Unicode-only characters


  • Subject: Re: Producing Unicode-only characters
  • From: "Nigel Garvey" <email@hidden>
  • Date: Wed, 26 Oct 2005 10:03:06 +0100

Dave Lyons wrote on Tue, 25 Oct 2005 19:22:20 -0700:

>On Oct 25, 2005, at 3:01 PM, Nigel Garvey wrote:
>>   run script "«data utxt3048»"
>>
>> ... which of course makes a nice basis for a Unicode character
>> handler:
>>
>>   on unicodeCharacter(n)
>>     run script "«data utxt" & {n div 4096, n mod 4096 div 256, n
>> mod 256
>> div 16, n mod 16} & "»"
>>   end unicodeCharacter
>>
>>   unicodeCharacter(12360)
>
>Neat...but for anyone wanting to use that for arbitrary characters,
>note that as written it only works if each of the 4 hex digits in the
>character code is from 0 to 9.  Any digit A through F wreaks havoc.
>(For example, 12367 turns into «data utxt30415» rather than «data
>utxt304F».)

Yes. I woke up realising that this morning. Also that it depends on the
TIDs not having been left as something stupid. Sorry.  :-(

In fact though, even after correction, it's quite slow. It seems to be
faster and more flexible to use a temporary file for this too: for
instance, the reverse of kai's adaptation of the Unicode-to-number method:

  on unicodeString(nl)
    set nl to nl as list
    set fref to (open for access file ((path to temporary items as
Unicode text) & "utxt scratch.txt") with write permission)
    try
      set eof fref to 0
      repeat with i from 1 to (count nl)
        set n to item i of nl
        write n to fref as small integer
      end repeat
      set uText to read fref as Unicode text from 1
    end try
    close access fref
    return uText
  end unicodeString

  unicodeString({12360, 12375})

By "faster", I mean "much faster when there are two numbers but as yet
untested with thousands."

NG

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Prev by Date: Re: Producing Unicode-only characters
  • Next by Date: Problem accessing file types after copying to server volume
  • Previous by thread: Re: Producing Unicode-only characters
  • Next by thread: Re: Producing Unicode-only characters
  • Index(es):
    • Date
    • Thread