• 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
Saving with Encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving with Encoding


  • Subject: Saving with Encoding
  • From: "Gerriet M. Denkmann" <email@hidden>
  • Date: Fri, 26 Oct 2012 16:42:48 +0700

My NSDocument subclass overrides fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error: and returns:
    CharacterEncoding = 2147484701; ← Thai (Windows, DOS)
    DocumentType = NSPlainText;
    UTI = "public.plain-text";

When I open the file again I get in readFromURL:ofType:error:
    CharacterEncoding = 30; ← Western (Mac OS Roman)
    DocumentType = NSPlainText;
    UTI = "public.plain-text";
And of course, it looks like complete rubbish.

There are no extendedAttributes to be seen (xattr -l reports nothing).

When I open the file in TextEdit (specifying Thai (Windows, DOS) in the OpenPanel) I get readable stuff.
And when I save the file with TextEdit there is an extended attribute: com.apple.TextEncoding = cp874;1053.

Opening the file again with my app I get the correct encoding and everything looks fine.

How is this supposed to work?
What am I missing? Do I have to set the extended attribute myself?

TextEdit seems to override fileWrapperOfType:error: - is this the only way to get the extended attribute written?
What is the point of  fileAttributesToWriteToURL:ofType:forSaveOperation:originalContentsURL:error:  if the dictionary returned is simply ignored?

Gerriet.



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:

This email sent to email@hidden


  • Prev by Date: Re: Binding InfoPanel to currentDocument
  • Next by Date: Re: Binding InfoPanel to currentDocument
  • Previous by thread: Re: Keyboard shortcut for menu item with submenu?
  • Next by thread: Need faster approach to load data in NSTableView from a file
  • Index(es):
    • Date
    • Thread