return unicode from osascript command

I am performing an Applescript from the command line that returns the entire contents of a directory. In that directory there are Japanese characters. When I get the return result of the call it seems the Japanese characters are not stored properly (not stored as utf-16??)

Has anyone had successful results returning utf-16 text from osascript? How does one return utf-16 text?


I just did a little test, and the stdout output from an Applescript does indeed appear to be UTF-8.

(Damn! I keep doing that on these bulletin boards… trying to add a new reply, but editing an old reply instead and replacing it. D’oh!)

At any rate, I had speculated that the output might be UTF-8, and it looks like I was right. UTF-8 will give you your Japanese characters, you just have to process it correctly to get the right results. Japanese characters will be three byte sequences in a UTF-8 stream. Basic ASCII uses one byte, lower Unicode (up to 0x07FF, I believe) uses two bytes, and Unicode up to 0xFFFF uses three bytes.