Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Dealing with Unicode strings into AppleScript code?

Dealing with Unicode strings into AppleScript code?
Thread Tools
Grizzled Veteran
Join Date: Dec 2000
Location: Málaga, Spain, Europe, Earth, Solar System
Status: Offline
Reply With Quote
Feb 4, 2003, 03:57 AM
 
Hello there,

I am trying to create some Unicode strings inside an AppleScript code. But I do not know how.

It seems that AS can handle Unicode text just well, as I have typed some Unicode characters in TextEdit and I was able to grab them just well using AS...

Any ideas? Thanks in advance.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Feb 4, 2003, 04:24 AM
 
AppleScript Language Guide Page 90

Code:
set myString to "Hello World" as Unicode Text
then if you want it as a basic sting again you can cast it as a string:

Code:
Log (myString as String)
     
eevyl  (op)
Grizzled Veteran
Join Date: Dec 2000
Location: Málaga, Spain, Europe, Earth, Solar System
Status: Offline
Reply With Quote
Feb 4, 2003, 04:28 AM
 
I already know that, but I do not want a normal ASCII string into a Unicode string variable.

I want to input special Unicode characters like dingbats, Japanese and the like. Into the code.
     
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 7, 2003, 06:52 PM
 
Unfortunatly, this isn't possible.

If you really need a string, you can either put it into your localizable.strings file and call it by using
set theString to localized string "theName" from table "theFileName"
or you can save it into a file and load it by using
set theFileLocation to "foo/bar/whatever.foo"
set theString to read POSIX file theFileLocation as Unicode text
I hope we can directly input it in the future.
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Feb 8, 2003, 04:22 PM
 
The AppleScript language can handle Unicode variables (after all, it can handle arbitrary bags of bytes), but the AppleScript compiler and the Open Scripting Architecture it's based on are designed for 8-bit text. So you can't put Unicode characters in string literals in your script (though as guifa points out, AppleScript Studio provides a workaround for loading strings from an external file).

"Real" Unicode support in AppleScript requires some dramatic changes under the hood... thankfully, that's just what Apple is doing. At WWDC 2002 they previewed "AppleScript X", which has a Unicode compiler and uses only Unicode strings in the language/runtime (instead of the, like, eight string types we have now). Looks spiffy.
Rick Roe
icons.cx | weblog
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:44 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2