Python for Vcard Parsing in UTF16

Alex Martelli aleax at mac.com
Sun Apr 22 02:04:03 CEST 2007


R Wood <rwood at therandymon.com> wrote:
   ...
> alias Linus_Torvalds Linus Torvalds <lt at linux.com>
> 
> To me this was a natural task for Perl.  Turns out however, there's a catch.
> Apple exports the file in UTF-16 to ensure anyone with Chinese characters in
> their addressbook gets a legitimate Vcard file.  And of course Perl somewhat
> chokes on UTF.  I've found several ways to do it that involve complicated
> downloads and installations of Perl modules, but that defeats the purpose of
> making it simple. In an ideal world you should be able to say "try this cool
> script" and be done with it.  Once you have to say "go to CPAN, download and
> compile this module, then ..." it gets less exciting.
> 
> I know nothing about Python except that it interests me and has interested me
> since I first learned the Rekall database frontend (Linux) runs on it.  I just
> ordered Learning Python and if that works out satisfactorily I'm going to go
> back for Programming Python.  In the meantime, I thought I would pose the
> question to this newsgroup: would Python be useful for a parsing exercise like
> this one?

Sure, Python and Perl (and Ruby) should be equally suitable for the
task, so, if Python appears more suitable by having built-in unicode
capabilities, go for it.  I'm a bit uncertain about the UTF-16 export
though; I know some applications do use it (e.g., Microsoft Entourage),
but I thought Apple's Address Book didn't, and, having just tried a
VCard export from mine, it looks quite ASCII to me.  Maybe you've set
some kind of preference, or...?


Alex



More information about the Python-list mailing list