• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: text Encoding with Write to file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text Encoding with Write to file


  • Subject: Re: text Encoding with Write to file
  • From: Bastiaan Boertien <email@hidden>
  • Date: Mon, 9 Jan 2006 12:56:01 +0100

This Is not the problem.
The script I send was for example and this source code never seen script editor on my machine.


That write [...] as string will not return in an error is true.
When the file contents start with §• there is still no error but when you open the terminal and you type 'file path/to/filename' it will return 'binairy graphic metafile' and it has to be 'ASCII text, with CR, LF line terminators'.
When you type 'pico path/to/filename' you will see that the text isn't MacRoman. That's why I was saying that 'write [...] as string' is not working.
To make the encoding in MacRoman I added the iConv handler in the script example in the previous mail.
But the question was can I do this last step directly in Script maker without using Iconv because write [...] as string is unreliable.


BTW I have also Mac OS 10.4.3.

Greetings Bastiaan

Op 9-jan-2006, om 11:38 heeft jj het volgende geschreven:

Well the problem is that I want to write a file with MacRoman text
encoding. I found a lot on the internet and it doesn't work

They said that write [...] as string will be MacRoman text encoding
but this doesn't work.

Works flawlessly here (OS X 10.4.3).

Anyway, where are you writing your scripts. It's that the line:

on write(theFile, theContents)

Should compile as:

on write {theFile, theContents}

And overriding osaxen commands isn't considered a safe practice ;-)

For instance:

###############################
on write {theFile, theContents}
    try
        set fd to open for access file theFile with write permission
        set eof of fd to 0
        write theContents to fd -- this will be UTF-16
        close access fd
    on error ErrMsg
        close access fd
        display dialog ErrMsg
    end try
end write
###############################

The line "write theContents..." should be calling to your handler itself, as
you're fake-re-defining the meaning and usage of the command "write". And,
as such, throwing an error, as "theContents to fd" doesn't match the
expected parameters for "on write {theFile, theContents}". On the other
hand, if it would, you would have an infinite loop...



jj


-- http://www.macscripter.net/ http://www.osaxen.com/


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: text Encoding with Write to file
      • From: jj <email@hidden>
References: 
 >Re: text Encoding with Write to file (From: jj <email@hidden>)

  • Prev by Date: similar strings
  • Next by Date: Re: text Encoding with Write to file
  • Previous by thread: Re: text Encoding with Write to file
  • Next by thread: Re: text Encoding with Write to file
  • Index(es):
    • Date
    • Thread