Unicode is messed up

Hi there,

first post for me, already wanted to say thanks to the many other replies I’ve found very useful. Ok, I’m writing code for AppleScript Studio but I think it has more to do with AppleScript since I can reproduce it in Script Editor. So here i go, I want my app to save a doc with the AppleScript Studio command “Write to File”. I’m writing Japanese characters and end up with crap. I get the same in Script Editor only by compiling it:

set thtest to “㈱” as Unicode text
display dialog thtest

Before I save it it’s all ok, the Japanese character is purple.

Then I compile and here’s what I get:

set thetest to “áM” as Unicode text

display dialog thetest

Can anyone tell me what’s going on?

The AppleScript compiler isn’t Unicode-aware: it reads text in your old-school primary encoding, which on an English system would be MacRoman. Since you’re in Studio, the simplest thing would be to put all your non-ASCII text in resource files within the application bundle and read them in as needed. See the ‘localized string’ command.

HTH

Ha! Thanks.

To incorporate special characters in a regular script, you might like to check out: Using Unicode-only characters in script strings.