Those files are created whenever you drag a text selection to the Finder. The file size is always 0 bytes
. Apparently the data is stored in a resource fork.
I tried reading the resource fork[1], but get error code -39
(end of file).
Here some more details about the file:
$>xattr test.textClipping
com.apple.FinderInfo
com.apple.ResourceFork
[1] http://www.cocoadev.com/index.pl?UsingResourceForks
NOTE: TEXTCLIPPING files can be viewed by double clicking them in Mac OS X. When opened, their text can be manually selected, copied, and then pasted into another document.
textClipping is an extension used by Macintosh computers for strings of text since Mac OS 9. When a string of text is selected and dragged to the desktop or anywhere on a Macintosh computer, the computer automatically converts it into a . textClipping file.
Text Clipping is a process of clipping the string. In this process, we clip the whole character or only some part of it depending upon the requirement of the application. Text clipping Methods : All or None String Clipping method – In this method, if the whole string is inside the clip window then we consider it.
A textClipping file is an old fashioned resource fork file. You'll want to open it using FSOpenResourceFile
, and then use Get1Resource
to read the resources out of the file. The file might contain a few different resources types for the text: 'RTF ' (rich text), 'utxt' (UTF-8), 'utf8' (UTF-8), or 'TEXT' (ASCII) type resources, all with id 256. Once you read the resource, extract the data from the Handle and do with it what you want.
It looks like in macOS 10.12 Sierra, a .textClipping file is now a property list.
The root dictionary has the key "UTI-Data". Within that, the keys: com.apple.traditional-mac-plain-text, public.utf16-plain-text, and public.utf8-plain-text hold a couple different representations of the data.
Here's an example that will read from a path:
NSString *path = @"/path/to/file.textClipping";
NSData *data = [NSData dataWithContentsOfFile:path];
id plist = [NSPropertyListSerialization propertyListWithData:data options:0 format:nil error:&error];
NSString *text;
if (plist && error == nil) {
NSDictionary *utiData = [plist objectForKey:@"UTI-Data"];
text = [utiData objectForKey:@"public.utf8-plain-text"];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With