A very easy way to get to the address book (and anything that supports Applescript/Apple events) from a higher level language is via http://appscript.sourceforge.net/
why use the MacRoman character set? UTF8 is a much better default.
also, the code uses CFStringGetCStringPtr() as if it can't ever fail. from the docs: "This function either returns the requested pointer immediately, with no memory allocations and no copying, in constant time, or returns NULL. If the latter is the result, call an alternative function such as the CFStringGetCString() function to extract the characters"
If you're going for safety, you should check to make sure that the string can use the particular encoding, rather than assuming that it will work. CFStringIsEncodingAvailable() will do that for you :)
no. CFStringIsEncodingAvailable() tells you whether a particular encoding is available on THE CURRENT COMPUTER, not for the given string.
i brought up the CFStringGetCStringPtr() issue because my experience is that it works okay if you're using nothing but plain ascii for inputs and outputs, but tends to fail when anything more esoteric is involved. it is not just a theoretical concern, it has happened to me in the wild, with paying customers involved. on the other hand, i think it's reasonable to assume that every mac in existence will be able to handle UTF8.
this episode is reminding me that far too many programmers assume ascii everywhere. be nice to foreigners, folks.
Why not CSV? S-Expressions are tree-structured, and that makes it easier to handle things like whether or not someone has a spouse (or multiple spouses) or a partner, or whether they have a title.
To parse S-Expressions, you just use (read) in Racket (or any Scheme for that matter). CSV isn't hard to parse, but it's not a 6-character expression.
Why not JSON? JSON is tree-structured, so it accounts for the issues above. But, most languages that slurp JSON don't have pattern-matching facilities as powerful as Racket.
If you look at the patterns I wrote to chew up entries and spit out labels, you'll see what I'm talking about.
Finally, the outputted S-Expressions are very human-readable.
racket (and scheme) can read sexprs from a port with the 'read' procedure, which then uses the interpreter's parsing engine. loading csv or json require modules.
and it's no more difficult for C to spit out strings with some parens in them than it is strings with commas.
Check out Duck Duck Go; it pulls snippets from Wikipedia and other data sources right to the top of search results, which makes it easy to get the gist of what something is, without much digging: http://duckduckgo.com/?q=mail+merge
Hm, somehow the first hits look like ads - perhaps a change of fonts would be helpful? In any case, none provides the quick answer I was looking for (I already guessed it is about mergin mails). But thanks!
I previously wrote something in Python to sync between LDAP and the OS X address book using appscript. It was fairly straightforward. Edited to add: https://github.com/jaysoffian/absync/blob/master/absync