Re: handling Unicode text
Re: handling Unicode text
- Subject: Re: handling Unicode text
- From: Christopher Nebel <email@hidden>
- Date: Sat, 10 Jan 2004 11:28:23 -0800
On Jan 9, 2004, at 11:41 PM, Donald Hall wrote:
Does AppleScript handle Unicode text that has no ASCII equivalent
(e.g. Japanese characters)? I get the contents of a file using the
following script:
...
set theData to (read dataFileRef from 1 to eof as {Unicode text}
using delimiter {return,
linefeed})
...
If you're not using Panther, that's your problem there. There's a bug
prior to Panther that using "using delimiter", "before", or "until"
will force the file contents to be interpreted as plain text, not
whatever you specified. You can upgrade to Panther, or read without
the delimiter and break it apart inside AppleScript, like this:
set theRawData to (read dataFileRef as Unicode text)
set theData to every paragraph of theRawData
-- breaks on CR, LF, CRLF, PARASEP, and LINESEP.
Notice that you don't need "from 1 to eof" -- that's the default -- and
that the "as" type should *not* be in a list. The only reason that's
still supported is because it appeared in an example in the old
Scripting Additions Guide.
Once you read Unicode text, you may or may not be able to see it
correctly in the result window. AppleScript pushes everything through
styled text internally to display it, so Unicode-only characters such
as Arabic or Thai will be mangled. Japanese should be fine, though.
--Chris Nebel
AppleScript Engineering
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.