 |
 |
Dealing with Unicode strings into AppleScript code?
|
 |
|
 |
|
Grizzled Veteran
Join Date: Dec 2000
Location: Málaga, Spain, Europe, Earth, Solar System
Status:
Offline
|
|
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
|
|
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)
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Dec 2000
Location: Málaga, Spain, Europe, Earth, Solar System
Status:
Offline
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|