TOC

vCard (.vcf)

VCF 是 Virtual Contact File 的简写,虚拟通讯录文件(电子名片文件可能更合适一些)。
PS:.vcf 后缀还有一个含义是 Variant Call Format,用在基因生物学方面。

关于

vCard(或称做 Versitcard)最早是由 Versit 联盟于 1995 年提出的,当时联盟成员包括苹果公司,AT&T 科技(后来的朗讯),IBM 及西门子。
在 1996 年十二月,格式的拥有权移至互联网邮件联盟(IMC),此联盟是由一些关注互联网电子邮件的公司所组成。
与 vCard 一同提出的用于数据交换的标准还有 vCalendar,但现在被 iCalendar 所取代。互联网邮件联盟已经声明它希望 “所有的 vCalendar 开发者利用这些新的开放标准,并使软件能够同时兼容 vCalendar 1.0 和 iCalendar。”

vCard 标准的 2.1 版被电子邮件客户端广泛支持。3.0 版是一个包含在 RFC 2425 和 RFC 2426 中的 IETF 标准跟踪提案。vCard 的常用副档名是.vcf。

不同的程序对 vCard 标准实现亦不同。Mac OS X 中的 Address Book 允许把所有联系人导出到一个 vcf 文件,而 Microsoft Outlook 只能每人一个文件。Linux 中 KDE 的 Kontact 允许每个文件导入或导出一人或多人。

示例

BEGIN:VCARD
VERSION:2.1
N:Gump;Forrest
FN:Forrest Gump
ORG:Gump Shrimp Co.
TITLE:Shrimp Man
TEL;WORK;VOICE:(111) 555-1212
TEL;HOME;VOICE:(404) 555-1212
ADR;WORK:;;100 Waters Edge;Baytown;LA;30314;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:100 Waters Edge=0D=0ABaytown, LA 30314=0D=0AUnited States of America
ADR;HOME:;;42 Plantation St.;Baytown;LA;30314;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:42 Plantation St.=0D=0ABaytown, LA 30314=0D=0AUnited States of America
EMAIL;PREF;INTERNET:forrestgump@walladalla.com
REV:20080424T195243Z
END:VCARD

字段列表

Name v2.1 v3.0 v4.0 Description Example
ADR Optional Optional Optional 结构化地址信息 ADR;TYPE=home:;;123 Main St.;Springfield;IL;12345;USA
AGENT Optional Optional Undefined 相关的人,比如秘书,可以是 URL 或内嵌 vCard AGENT:http://mi6.gov.uk/007
ANNIVERSARY Undefined Undefined Optional 纪念日 ANNIVERSARY:19901021
BDAY Optional Optional Optional 生日 BDAY:19700310
BEGIN Required Required Required 开始标记 BEGIN:VCARD
CALADRURI Undefined Undefined Optional 用于向个人日历发送日程安排请求的 URL。 CALADRURI:http://example.com/calendar/jdoe
CALURI Undefined Undefined Optional A URL to the person's calendar. CALURI:http://example.com/calendar/jdoe
CATEGORIES Optional Optional Optional A list of "tags" that can be used to describe the object represented by this vCard. CATEGORIES:swimmer,biker
CLASS Undefined Optional Undefined Describes the sensitivity of the information in the vCard. CLASS:public
CLIENTPIDMAP Undefined Undefined Optional Used for synchronizing different revisions of the same vCard. CLIENTPIDMAP:1;urn:uuid:3df403f4-5924-4bb7-b077-3c711d9eb34b
EMAIL Optional Optional Optional 邮箱地址 EMAIL:johndoe@hotmail.com
END Required Required Required 结束标记 END:VCARD
FBURL Undefined Undefined Optional Defines a URL that shows when the person is "free" or "busy" on their calendar. FBURL:http://example.com/fb/jdoe
FN Optional Required Required The formatted name string associated with the vCard object. FN:Dr. John Doe
GENDER Undefined Undefined Optional 性别 GENDER:F
GEO Optional Optional Optional 地理位置 2.13.0GEO:39.95;-75.1667
4.0GEO:geo:39.95,-75.1667
IMPP Undefined Maybe Optional Defines an instant messenger handle.This property was introduced in a separate RFC when the latest vCard version was 3.0. Therefore, 3.0 vCards might use this property without otherwise declaring it. IMPP:aim:johndoe@aol.com
KEY Optional Optional Optional 公钥 2.1KEY;PGP:http://example.com/key.pgp
2.1KEY;PGP;ENCODING=BASE64:[base64-data]
3.0KEY;TYPE=PGP:http://example.com/key.pgp
3.0KEY;TYPE=PGP;ENCODING=b:[base64-data]
4.0KEY;MEDIATYPE=application/pgp-keys:http://example.com/key.pgp
4.0KEY:data:application/pgp-keys;base64,[base64-data]
KIND Undefined Undefined Optional Defines the type of entity that this vCard represents: 'application', 'individual', 'group', 'location' or 'organization'; 'x-*' values may be used for experimental purposes. KIND:individual
LABEL Optional Optional Incorporated without 收货地址(Mailing Label),4.0 作为 LABEL 参数并入 ADR 属性,例如:ADR;TYPE=home;LABEL="123 Main St\nNew York, NY 12345":;;123 Main St;New York;NY;12345;USA LABEL;TYPE=HOME:123 Main St.\nSpringfield, IL 12345\nUSA
LANG Undefined Undefined Optional 语言 LANG:fr-CA
LOGO Optional Optional Optional 所属组织的 LOGO 2.1LOGO;PNG:http://example.com/logo.png
2.1LOGO;PNG;ENCODING=BASE64:[base64-data]
3.0LOGO;TYPE=PNG:http://example.com/logo.png
3.0LOGO;TYPE=PNG;ENCODING=b:[base64-data]
4.0LOGO;MEDIATYPE=image/png:http://example.com/logo.png
4.0LOGO;ENCODING=BASE64;TYPE=PNG:[base64-data]
MAILER Optional Optional Undefined 邮件客户端 MAILER:Thunderbird
MEMBER Undefined Undefined Optional 定义当前 vCard 代表的组织的一个成员,mailto 或 UID。
需要:KIND  为 group
MEMBER:urn:uuid:03a0e51f-d1aa-4385-8a53-e29025acd8af
N Required Required Optional A structured representation of the name of the person, place or thing associated with the vCard object. N:Doe;John;;Dr;
NAME Undefined Optional Undefined SOURCE 属性的文本描述
NICKNAME Undefined Optional Optional 昵称/别名 NICKNAME:Jon,Johnny
NOTE Optional Optional Optional 备注 NOTE:I am proficient in Tiger-Crane Style,\nand I am more than proficient in the exquisite art of the Samurai sword.
ORG Optional Optional Optional The name and optionally the unit(s) of the organization associated with the vCard object. This property is based on the X.520 Organization Name attribute and the X.520 Organization Unit attribute. ORG:Google;GMail Team;Spam Detection Squad
PHOTO Optional Optional Optional 照片,URL 或 Base64 2.1PHOTO;JPEG:http://example.com/photo.jpg
2.1PHOTO;JPEG;ENCODING=BASE64:[base64-data]
3.0PHOTO;TYPE=JPEG;VALUE=URI:http://example.com/photo.jpg
3.0PHOTO;TYPE=JPEG;ENCODING=b:[base64-data]
4.0PHOTO;MEDIATYPE=image/jpeg:http://example.com/photo.jpg
4.0PHOTO;ENCODING=BASE64;TYPE=JPEG:[base64-data]
PRODID Undefined Optional Optional The identifier for the product that created the vCard object. PRODID:-//ONLINE DIRECTORY//NONSGML Version 1//EN
PROFILE Optional Optional Undefined States that the vCard is a vCard. PROFILE:VCARD
RELATED Undefined Undefined Optional Another entity that the person is related to. Acceptable values include:
- a "mailto:" URL containing an email address
- a UID which references the person's own vCard
RELATED;TYPE=friend:urn:uuid:03a0e51f-d1aa-4385-8a53-e29025acd8af
REV Optional Optional Optional A timestamp for the last time the vCard was updated. REV:20121201T134211Z
ROLE Optional Optional Optional The role, occupation, or business category of the vCard object within an organization. ROLE:Executive
SORT-STRING Undefined Optional Incorporated without 排序字符串,4.0 作为  SORT-AS  参数,并入  N and/or ORG  属性 SORT-STRING:Doe
SOUND Optional Optional Optional FN 的读音? 2.1SOUND;OGG:http://example.com/sound.ogg
2.1SOUND;OGG;ENCODING=BASE64:[base64-data]
3.0SOUND;TYPE=OGG:http://example.com/sound.ogg
3.0SOUND;TYPE=OGG;ENCODING=b:[base64-data]
4.0SOUND;MEDIATYPE=audio/ogg:http://example.com/sound.ogg
4.0SOUND:data:audio/ogg;base64,[base64-data]
SOURCE Optional Optional Optional vCard 更新地址(URL) SOURCE:http://johndoe.com/vcard.vcf
TEL Optional Optional Optional 电话号码 TEL;TYPE=cell:(123) 555-5832
TITLE Optional Optional Optional 职位 TITLE:V.P. Research and Development
TZ Optional Optional Optional 时区 2.13.0TZ:-0500
4.0TZ:America/New_York
UID Optional Optional Optional 当前对象的 UUID UID:urn:uuid:da418720-3754-4631-a169-db89a02b831b
URL Optional Optional Optional 网站 URL:http://www.johndoe.com
VERSION Required Required Required vCard 版本 VERSION:3.0
XML Undefined Undefined Optional 附带 XML 数据(vCard 采用 xCard 编码,然后需要附带非 xCard 标准数据的时候) XML:<b>Not an xCard XML element</b>

Python 相关

基本上没有一个非常合意的库:vCard 这么简单的格式,应该更简单才对。

我自己写了一个小脚本来解析。没有打磨,有点乱,就不贴出来了。

MeCard

参考 vCard 的设计,仅支持单个联系人,几个属性(;; 隔开),生成二维码(QR)。

Tag Description Example
ADR 收货地址 ADR:,,,Wuhan,Hubei,430000,PRC;
BDAY 生日,yyyymmdd BDAY:19700310;
EMAIL 电子邮箱 EMAIL:huang@sendcloud.im;
N 名称:姓(lastName),名(firstName) N:胡,昂;
NICKNAME 昵称 NICKNAME:Johnny;
NOTE 备注 NOTE:Developer;
SOUND 名字发音(拼写) SOUND:Hu,Ang
TEL 电话号码 TEL:(123) 555-5832;
TEL-AV 视频电话号码(?) TEL-AV:(123) 555-5832;
URL 网址 URL:https://www.markjour.com/

地址格式:
PO box > room number > house number > city > prefecture > zip > country
信箱 > 房号 > 门牌号 > 城市 > 省份 > 邮政编码 > 国家

External links

参考资料与拓展阅读