Unicode form of text

A while back I asked a question which ultimately ended up with Kai posting some code that had this in it.

repeat with s in «data utxt2661266326622660» as Unicode text

The data is four characters that represent the suits of a deck of cards. I found these characters using TextEdit and decided to play around with this trying to display other characters. The problem I’m having, though, is getting the actual unicode data of any text. In the scripting guide they show the simple script:

set h to "hello" as Unicode text

with a result in the form of «data utxtblahblah». I’m currently in AppleScript 1.10. This just shows the same “hello” in the result. I was trying to get the characters I wanted to use from TextEdit and convert them to unicode to get the data so I could input that data as Kai has, but cannot figure out how to get the actual Unicode data.

Thanks.

PreTech

If you can type the character, then try getting the information from Key Codes. (Otherwise, I would look online.) You’ll see something like this:

The stuff after 0x (hex) is what you want. Remember that you need four digit, so if you have less than that, add zeroes to the front. “hello” would look like this:

«data utxt00680065006C006C006F» as Unicode text

Edit: Also, you might look at this: http://www.isthisthingon.org/unicode/index.phtml

Edit: This looks better: http://slayeroffice.com/tools/unicode_lookup/

Thanks Bruce. These help some, but the characters I’m looking for I can’t seem to get to from keyboard strokes. I have to open the character palette to get to them. As far as I can tell these characters cannot be typed directly from the keyboard. I’m looking for the funky little picture type characters.

In the two websites, if I copy and paste the character I’m looking for, they can’t seem to interpret them.

PreTech

Hi, PreTech;

I run this little script and then pick the character I want from the display. The code is given just above the pane showing the symbols.

tell application "System Events"
	if exists process "CharPaletteServer" then
		do shell script "killall CharPaletteServer"
	else
		tell application "CharPaletteServer" to activate
	end if
end tell

D’oh!:o Thanks guys! If I had but looked farther down the dropdown list at the top of the character palette, I’d have seen the light!

PreTech

Um, yeah, there’s that too. :rolleyes: I had problems with that in the early days of Tiger, so I’ve forgotten about the palette until recently. :slight_smile:

You might also like to check out the discussion about Using Unicode-only characters in script strings, PreTech. (The script at the end may be quite handy for what you’re trying to do…)

:slight_smile:

Interesting that the convertor works nicely in Script Editor and errors “can’t continue…” in Script Debugger 4.

There shouldn’t be a problem with the convertor part of the script. However, Script Debugger may have difficulty making and/or executing new documents ” which the demo section of the script aims specifically at Script Editor. (While you don’t say exactly what Script Debugger “can’t continue…”, I imagine it’s primarily the execute command from the Script Editor Suite.)

For more general purposes, you’d probably be better off using something like this variation:

Use with the utxt_data handler at the end of this:

set the clipboard to (utxt_data from text returned of (display dialog "Enter or paste the text to copy as Unicode data:" default answer return buttons {"Cancel", "Copy"} default button 2) with coercing)

It’s simpler, Kai; The problem I had forgotten is that Script Debugger 4 is not really scriptable. Sorry to have bugged you. :rolleyes:

Sorry I hadn’t replied, but I got tied up trying to do more Illustrator stuff.

Thanks to you all. Kai, as always, your scripting abilities are astounding! The link to your discussion was great. I keep trying to cram all this info into my head but I keep getting this error though . . . something like . . . Way to big dude. :lol::lol::lol:

PreTech