• 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: Writing Text files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing Text files


  • Subject: Re: Writing Text files
  • From: Andreas Kiel <email@hidden>
  • Date: Sat, 17 Nov 2012 10:15:55 +0100

Thanks Rainer,

The problem is not that the AS code doesn't work.
The problem is that other apps sometimes screw up the text encoding when reading the files.
As mentioned in the example the resulting text file works fine for TextEdit on some OS versions and not on others (using UTF8). Using UTF16 works fine for TextEdit but not for TextWrangler or BBEdit.
Using this code running ML will make the text file readable for TextEdit on ML but TextEdit on 10.6.x can't read it correctly.
To enter a BOM to the UTF8 doesn't help as well.

Andreas

On Nov 16, 2012, at 7:01 PM, Rainer Standke wrote:

> Not sure about the syntax in AppleScript, but the last parameter that you are passing (1) probably should be an error object, or rather a reference to it. You can also pass the AppleScript equivalent of nil, but I'm not sure what that might be. Unlikely that it's 1, though.
>
> Hope this helps.
>
> Rainer
>
>
> On Nov 5, 2012, at 7:17, Andreas Kiel <email@hidden> wrote:
>
>> Hi all,
>>
>> I'm trying to bring some sense into a problem saving text files either in UTF8 or UTF16.
>>
>> so I use either a
>> 					call method "writeToFile:atomically:encoding:error:" of someText with parameters {savePath, true, 4, 1}
>> or a
>> 					call method "writeToFile:atomically:encoding:error:" of someText with parameters {savePath, true, 16, 1}
>>
>> Depending on OS and application which reads the file this either works or doesn't work.
>> For example I can open one of the text files in TextEdit and it shows up fine with all special characters, using another app special characters are screwed up (saving with UTF8)
>> Using UTF16 sometimes causes with some apps a total screw up of all characters while others work fine.
>>
>> Any ideas for a workaraound. I've searched the web how to add a BOM to the files, but haven't found anything.
>>
>> Any ideas out there?
>>
>> Regards
>> Andreas
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> applescriptobjc-dev mailing list      (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Writing Text files (From: Andreas Kiel <email@hidden>)

  • Prev by Date: Writing Text files
  • Next by Date: Re: Writing Text files
  • Previous by thread: Writing Text files
  • Next by thread: Re: Writing Text files
  • Index(es):
    • Date
    • Thread