handling Unicode text
handling Unicode text
- Subject: handling Unicode text
- From: Donald Hall <email@hidden>
- Date: Sat, 10 Jan 2004 00:41:05 -0700
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.