Re: Question about line breaks and file types
Re: Question about line breaks and file types
- Subject: Re: Question about line breaks and file types
- From: Dustin Voss <email@hidden>
- Date: Mon, 4 Aug 2003 16:49: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.
In simple text files, there is no connection. BBEdit replaces all line
breaks with the type you specify. In RTF files, there might be a
specified line break character.
The Unicode Consortium has recommendations on the subject of line
breaks. It is in Unicode 4.0, but I don't have a copy. It probably has
not changed since
http://www.unicode.org/reports/tr13/tr13-9.html:
* If you know the line break is being used to separate paragraphs,
replace it with U+2029 (Paragraph Separator).
* If you know the line break is being used to separate lines, replace
it with U+2028 (Line Separator).
* If you don't know, replace it with your platform's line break
character ('\n'). This will be 0x0D or 0x0A. I know it was 0x0D in
Classic, but I think Unixes use 0x0A. Just use '\n', though.
Unfortunately, as I stated in another message, Cocoa might not consider
U+2028 or U+2029 to be line breaks. They aren't in [NSCharacterSet
whitespaceAndNewlineCharacterSet], anyway.
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?
Conceptually, strings aren't in UTF-8 or UTF-16 or anything in
particular. They only get an encoding when you call
"dataUsingEncoding:". Internally, though, I think Cocoa uses UTF-16.
The pasteboard can have several different representations. Text views
default to accepting and providing at least NSRTFPboardType or
NSStringPboardType clippings. If you want the text-view to ask for or
provide other, more specific clippings, override
"writablePasteboardTypes", "readablePasteboardTypes",
"writeSelectionToPasteboard:type:", and
"readSelectionFromPasteboard:type:".
_______________________________________________
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.