Encoding from and to Freeway

Hi,
I have a question abut text encoding. I write Actions for Freeway (a web design app - Actions are plug-ins that run JavaScript and AppleScript) . My current project involves a lot of text handling, and I’m at the edge of my knowledge here (I’m not a full time egnineer - I’m usually off doing design work). There is a requirement that this works in Japanese, and some elements of Freeway’s Actions interface can not handle Japaneses text. This is a large prompt/plain text eidor which is used to input a large amount of text. In the case of this . So, in its absence, I’m looking at replacing this with a small AppleScript studio app. Freeway will call the app using a bit of AppleScript, wait for a response, collect the text and continue.

So, I have a small AppleScript studio app that is a window with an NSScrollView box and a Save button. The plan is that the Action opens this, put in any exisitng text that it has into the NSScroll view, and when the Save button is clicked, Freeway will get the returned text. So far, it works with Western text. However, as I’ve hinted, Japanese is a problem.

Freeway encodes the text from whatever it uses internally to the page’s encoding. In the case of Japanese, it’s a choice of these:
iso-2022-jp
shift_JIS
euc-jp
These encodings are set by the user’s choice, and Freeway’s Japaneses handling in interface elements work only when one of these are chosen.

So, I pass suitably encoded Japanese text to an Applescript block (creaed by Freeway) which then loads it into the Applescript studio created application. At this point, encoding seems to be lost and in the AS app, I get garbled text.

I also need to pass Mac-Japanese back to Freeway. It has to be Mac-Japanese as this is what Freway uses for Japanese internally (OS9 throwback, I’m afraid).

My question is - how do I encode text to and from various Japanese settings? How do I set/read the encoding of the NSScrollView text to match that? I have downloaded this OSAX already, but the entire documentation and comments in the examplemscripts are in Japanese, which isn’t a lot of help because I can’t read it!

http://www.bekkoame.ne.jp/~iimori/sw/TECOSAX.html

If I can recieve/send Freeway friendly encoded Japanese text, then I should be OK. If not, I’ll have to abandon Japenese for the time being.

Thanks.

I believe that I’ve got the answer to this now, but any other suggestions would be welcomed. I converted between UTF-8 and Mac-Japanese.