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


Ilya Shebalin
 

Hi, Shane
I did that too, I tried every encoding that write cmd provide as a value of its as parameter. When I use "class utf8" I get an error. 

On Sat, Jun 16, 2018 at 2:25 AM Shane Stanley <sstanley@...> wrote:
On 16 Jun 2018, at 4:30 am, Ilya Shebalin <iljashebalin2@...> 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@...>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>





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