• 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: Question about line breaks and file types
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about line breaks and file types


  • Subject: Re: Question about line breaks and file types
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 4 Aug 2003 10:28:25 -0700

On Sunday, August 3, 2003, at 10:19 PM, Francisco Tolmasky wrote:

Is there a necessary connection between line breaks and file types. For example, should a unicode text file use unicode line breaks. I ask this because programs like BBEdit let you change the line break style on the fly, seemingly without changing the file type.

There is no necessary connection between the encoding and the line break types; in particular, just because a file is in UTF-16 or UTF-8 doesn't mean that it should use Unicode line breaks. In fact, the Unicode breaks are probably among the least likely to be recognized by code that doesn't recognize all of the types, so you probably shouldn't use them unless you have some compelling reason for doing so.

Secondly, if I have a textview with UTF 8 characters in it, and someone pastes something into it, do I have to do anything with it, like, for example convert it to UTF 8, or is it converted automatically or what?

The backing store for an NSTextView is an NSTextStorage, which is a subclass of NSMutableAttributedString. An NSMutableAttributedString consists of an NSString plus attributes, and NSString is conceptually a sequence of unichars--the actual storage may vary, but it is concealed by the NSString interface. You need to worry about encodings only when you are converting your text into some other form, for example if you are storing it in a plain text file.

As long as your text is within the text system, Cocoa takes care of it all for you. This includes handling encodings for all of the standard pasteboard types that Cocoa recognizes. If you were implementing your own custom pasteboard type, you might have to concern yourself with this.

Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Question about line breaks and file types
      • From: Chuck Soper <email@hidden>
References: 
 >Question about line breaks and file types (From: Francisco Tolmasky <email@hidden>)

  • Prev by Date: Re: QuickTime stops to play
  • Next by Date: Re: Compiler Warnings
  • Previous by thread: Question about line breaks and file types
  • Next by thread: Re: Question about line breaks and file types
  • Index(es):
    • Date
    • Thread