AppleScript: Using Unicode the Sneaky Way

May 24, '10 07:30:00AM

Contributed by: renaultssoftware

In my daily workflow, I often use AppleScript. Sometimes I need to use symbols in, say, TextEdit. Usually, you would open the Character Palette. But I found an interesting way to use AppleScript's power to insert Unicode characters using the «data» format in AppleScript.

AppleScript will let you use the «data» format for a lot of things. Images, for instance, can be stored in here. But since you're looking to use Unicode, we'll look at what AppleScript can do to make Unicode strings.

First of all, you need to know that Unicode text in AppleScript's «data» format is «data utxt». That means you have a blank, raw Unicode string. So after utxt, you can use the 4-digit code for the character. So, try this script in AppleScript Editor:

«data utxt2756»

That'll return «data utxt2756» literally, so, we need to add "as Unicode text" after, like this:

«data utxt2756» as Unicode text

You can do a lot of stuff with that string now.

[crarko adds: I tested this (in 10.6), and it works as described.]

Comments (11)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20100521142504726