Re: Manipulating text
Re: Manipulating text
- Subject: Re: Manipulating text
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 25 Sep 2009 12:11:28 -0400
That is just crazy. There's a reason the Unicode database has
case-folding rules. Rolling your own will be slow and incomplete at
best, buggy at worst.
Use TextCommands or Smile or Perl or Python or Ruby or any of the
zillions of tools that will do Unicode-aware case-conversion for you.
And we've talked about hex conversion before; I supplied sample
conversion functions that used native AS only and ones that shelled
out to the dc(1) utility. The AS-only ones were faster, as one might
expect.
On Fri, Sep 25, 2009 at 11:06 AM, Luther Fuller <email@hidden> wrote:
> A little looking-up and calculating lead me to this ...
> set firstWord to "åæçœøπxnchdgrtsjdlvmfqq12345"
> set charList to characters of firstWord
> repeat with i from 1 to (count items of charList)
> set charID to id of (item i of charList)
> if (96 < charID) and (charID < 123) then
> set charID to (charID - 32)
> set item i of charList to (character id charID)
> else if (223 < charID) and (charID < 254) then
> set charID to (charID - 32)
> set item i of charList to (character id charID)
> else if (255 < charID) and (charID < 376) then
> if (charID mod 2) = 1 then
> set charID to (charID - 1)
> set item i of charList to (character id charID)
> end if
> end if
> end repeat
> set firstWord to charList as text
> log firstWord
> Notice that "π" does not capitalize. There are more blocks in the unicode
> table that contain other upper/lower case pairs, so the script needs more
> else blocks. Have fun!
>
> _______________________________________________
> 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
>
--
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