Re: TextEdit won't open a plain text file after writing to it with write cmd


Shane Stanley
 

On 16 Jun 2018, at 4:30 am, Ilya Shebalin <iljashebalin2@gmail.com> wrote:

IIf the file exists and all the statements beyond "else" clause are executed then TextEdit gives a warning of a wrong encoding ("The document "theFile.txt" could not be opened. Text encoding Unicode (UTF-8) isn’t applicable.") and refuses to open the file.
You need to save the file as UTF-8 -- at the moment you're saving it in MacRoman. Change this:

write theText to FileID
to:

write theText to FileID as «class utf8»


--
Shane Stanley <sstanley@myriad-com.com.au>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>

Join applescript@apple-dev.groups.io to automatically receive all group messages.