Hi All,

I am still working on this after a night of sleep. The original Author used
Applescript and it has been a while since I have worked with AS.

I think that he is calling this when he writes out the file.

set the target_file to the target_file as text
        set the open_target_file to open for access file target_file with
write permission
        
        if new_file is true then write (ASCII character of 254) & (ASCII
character of 255) to open_target_file
        
        write this_data to the open_target_file starting at eof as Unicode
text
        close access the open_target_file
        return true

I think that my problem when I write new files back out is that I don't
write an ASCII Characters and I am using UTF versus Unicode.

How do I write an ASCII 254 and ASCII 255 at the beginning of the NSString
that I am putting in the file I want to be read back in at a later date? '

-Jason


On 3/18/08 10:47 PM, "Jens Alfke" <[EMAIL PROTECTED]> wrote:

> 
> On 18 Mar '08, at 9:53 PM, J. Todd Slack wrote:
> 
>> So how do I write out a text file in UTF16-BE encoding? Maybe this
>> would
>> solve my problem.
> 
> You *are* writing it out in that encoding; that's the problem. It's
> not the default text encoding, so apps won't interpret the text
> correctly. You generally want to save text files in UTF-8.
> 
>> if ([predefinedSessionDocumentsFileContents writeToFile:
>> pathToUsersImpressionDocumentsSessionFile atomically: YES]) {}
>>        else { NSLog (@"Failure writing Documents Session File On
>> Startup");
>> }
> 
> You want -writeToFile:atomically:encoding: instead. Pass
> NSUTF8StringEncoding as the last parameter.
> 
> (I'm kind of surprised that the method you're calling generates
> UTF-16. Maybe that's part of the reason it's marked as deprecated!)
> 
> ‹Jens



_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to