• 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: Dealing with Mac/Unix/Windows line breaks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dealing with Mac/Unix/Windows line breaks


  • Subject: Re: Dealing with Mac/Unix/Windows line breaks
  • From: Tom Sutcliffe <email@hidden>
  • Date: Wed, 6 Aug 2003 01:36:11 +0100

On Monday, August 4, 2003, at 11:55 pm, Dustin Voss wrote:

On Sunday, August 3, 2003, at 04:59 PM, Francisco Tolmasky wrote:

In a document that accepts copies from different sources, how should you deal with line breaks. For example, let's say you have a text view with macintosh line breaks. Someone hits copy from a document with unix line breaks, and then pastes to you text view. Do you now have a mixed format string in the text view? Do you have to intercept the string and convert the line breaks? Is there an easy way to do so, like [string stringWithLineBreaks: Mac]?

Unfortunately, there's no easy way I've found to convert line breaks. I don't know if NSString automatically converts all line breaks to '\n' or what.

As I understand it, proving the line breaks look right on screen in the app you're pasting from, it should provide them in the correct format onto the pasteboard. Since the only stuff I've done on this accepted files as well as pasteboard stuff it was written very defensively, so I'm not entirely sure though. It might be worth checking. Also if you paste stuff from an app which doesn't understand the line endings (eg they're displayed as boxes) then you'd possibly have problems. Again, check it with a test case, it's too late at night for me to :)

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?

Accented characters and the like will certainly be translated correctly - NSStrings are unicode so if you receive an nsstring from anywhere (eg the pasteboard server) you can be certain its characters are correct. And if it's not, it's somebody else's problem and you shouldn't try and hack it into shape :)

Regards,

Tom

Generating SEP's since 1998
_______________________________________________
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.

References: 
 >Re: Dealing with Mac/Unix/Windows line breaks (From: Dustin Voss <email@hidden>)

  • Prev by Date: Re: Cross platform development
  • Next by Date: Re: Invoking command line commands with environment variables set
  • Previous by thread: Re: Dealing with Mac/Unix/Windows line breaks
  • Next by thread: Trying to pre-populate NSTextFields, getting SIGBUS/SIGSEGV
  • Index(es):
    • Date
    • Thread