Q:

How can I use custom fields in a vCard? 

I'm writing an application which generates vCards from an internal customer database and would like to include additional information in the card, e.g. internal customer number.  Reading the RFC, I've see "vendor-specific" extensions, which are to be registered at IANA etc.  Are these extensions the way to go?  What should I keep in mind while using them, any pitfalls?  Are there any alternative ways to define a custom field in a vCard? 

A:

RFC 2426 section 4 specifies how to create non-standard names.  If you read the production rules, you'll get the exact way properties can be defined.  For example, to define a customer number, you could say simply X-CUSTOMER-ID:123 on a separate line. 
Things to beware:

Escaping characters like comma, semicolon, colon and newline.  This is well defined in the syntax rules. 
Which things are case sensitive and which are not.  Ditto. 
Encoding and line endings in the resulting file.  Just to use UTF-8, line endings \r\n (Windows style) and an extra empty line at the end of the file.