Re: handling Unicode text
Re: handling Unicode text
- Subject: Re: handling Unicode text
- From: Paul Berkowitz <email@hidden>
- Date: Sat, 10 Jan 2004 09:07:41 -0800
None of the current script editors will display real Unicode characters
(except by approximating those which can be approximated in the old
"international text" versions. Your two Japanese characters are evidently
not among those.) I believe it has to do with the AppleScript de-compiler,
rather than with any of the editors per se.
They can all grab the Unicode characters and transfer them to a scriptable
application that does display real Unicode, however. I have frequently
obtained Unicode from Entourage, written it to a file, read it as Unicode
from the file, and set some text field of Entourage to the result. Similarly
to and from Apple's Address Book. You can do it (with some effort) in
TextEdit as well.
--
Paul Berkowitz
>
From: Donald Hall <email@hidden>
>
Date: Sat, 10 Jan 2004 00:41:05 -0700
>
To: <email@hidden>
>
Subject: handling Unicode text
>
>
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:
>
>
------------------
>
property linefeed : ASCII number 10
>
>
set theFile to choose file
>
>
try
>
set theText to readData from theFile
>
theText as Unicode text
>
on error errMsg number errNum
>
display dialog errMsg & return & errNum
>
end try
>
>
to readData from aFile
>
set dataFileRef to (open for access aFile)
>
if (get eof dataFileRef) is 0 then
>
error "The data file \"" &
>
(POSIX path of aFile as text) & "\" is empty."
>
end if
>
set theData to (read dataFileRef from 1
>
to eof as {Unicode text} using delimiter {return,
>
linefeed})
>
close access dataFileRef
>
return theData
>
end readData
>
----------------------
>
>
My test file has two Japanese characters in it,
>
but they do not show correctly in either the
>
Smile Console window or the Script Editor Results
>
window. In fact, they come out as: "SH_e". In
>
addition, there seems to be extra characters:
>
"" before the first actual character in the
>
file. The file displays correctly in TextEdit.
>
>
Is there any way to have the characters show
>
correctly? What happens if the Japanese
>
characters are read from the file by a script, or
>
passed to a script as parameters?
>
>
Thanks for any insights,
>
>
Don
>
--
>
Donald S. Hall, Ph.D.
>
Apps & More Software Design, Inc.
>
email@hidden
>
http://www.appsandmore.com
>
_______________________________________________
>
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.
_______________________________________________
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.