On Wed, Apr 12, 2006 at 02:29:50AM +0900, Ben Reubenstein wrote:> I am using the Ruby Vpim library to create Vcards. I am having > trouble getting my address entries to format correctly when the > resulting VCF file is loaded into an address book. Is there a special > character to create a break line in the address field? Many of the > addresses in my data include multiple line addresses and they are > being forced into one line.Hi Ben, Lets move this conversation over to vpim-talk, so we don''t take up the attention of the entire ruby world. :-) Here''s an example of encoding a multiline street with vpim-0.360: % cat ex_multiline.rb require ''vpim/vcard'' card = Vpim::Vcard::Maker.make2 do |maker| maker.add_name do |name| name.prefix = ''Dr.'' name.given = ''Jimmy'' name.family = ''Death'' end maker.add_addr do |addr| addr.preferred = true addr.location = ''work'' addr.street = "12 Last Row,\n13th Section" addr.locality = ''City of Lost Children'' addr.country = ''Cinema'' end end puts card card = Vpim::Vcard.decode(card.to_s).first puts "---" puts card.address.street puts "---" % ruby -I ../lib -w ex_multiline.rb BEGIN:VCARD VERSION:3.0 N:Death;Jimmy;;Dr.; FN:Dr. Jimmy Death ADR;TYPE=work,pref:;;12 Last Row,\n13th Section;City of Lost Children;;;Cin ema END:VCARD --- 12 Last Row, 13th Section --- So, I think it works. If a card encoded like this doesn''t import correctly into your address book app, I''d like to see a card exported from your address book program that has newlines in the address fields, to see how it thinks things should be done. Also, the code you use to encode the address and the version of Vpim you are using would be helpful, and an example of a card you''ve encoded. Cheers, Sam
Hi Sam ~ Thx for the quick reply and the excellent library. I am trying to import the .vcf files into Outlook 2002 (gag!) and I think my issue might be that it wants version 2.1 cards :( I just installed Thunderbird thinking it would accept VCF files to test, but to my surprise it doesn''t. The vcf file saved by Outlook uses this format: ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Address Line 1 =0D=0AAddress Line 2 =0D=0AAddress Line 3;City;St;11111;United States of America Thx, Ben On 4/11/06, Sam Roberts <sroberts at uniserve.com> wrote:> On Wed, Apr 12, 2006 at 02:29:50AM +0900, Ben Reubenstein wrote: > > I am using the Ruby Vpim library to create Vcards. I am having > > trouble getting my address entries to format correctly when the > > resulting VCF file is loaded into an address book. Is there a special > > character to create a break line in the address field? Many of the > > addresses in my data include multiple line addresses and they are > > being forced into one line. > > Hi Ben, > > Lets move this conversation over to vpim-talk, so we don''t take up the > attention of the entire ruby world. :-) > > Here''s an example of encoding a multiline street with vpim-0.360: > > % cat ex_multiline.rb > require ''vpim/vcard'' > > card = Vpim::Vcard::Maker.make2 do |maker| > maker.add_name do |name| > name.prefix = ''Dr.'' > name.given = ''Jimmy'' > name.family = ''Death'' > end > > maker.add_addr do |addr| > addr.preferred = true > addr.location = ''work'' > addr.street = "12 Last Row,\n13th Section" > addr.locality = ''City of Lost Children'' > addr.country = ''Cinema'' > end > end > > puts card > > card = Vpim::Vcard.decode(card.to_s).first > > puts "---" > puts card.address.street > puts "---" > > % ruby -I ../lib -w ex_multiline.rb > BEGIN:VCARD > VERSION:3.0 > N:Death;Jimmy;;Dr.; > FN:Dr. Jimmy Death > ADR;TYPE=work,pref:;;12 Last Row,\n13th Section;City of Lost Children;;;Cin > ema > END:VCARD > --- > 12 Last Row, > 13th Section > --- > > So, I think it works. > > If a card encoded like this doesn''t import correctly into your address book > app, I''d like to see a card exported from your address book program that has > newlines in the address fields, to see how it thinks things should be done. > > Also, the code you use to encode the address and the version of Vpim you are > using would be helpful, and an example of a card you''ve encoded. > > Cheers, > Sam > > >-- Ben Reubenstein http://www.benr75.com
On Tue, Apr 11, 2006 at 01:38:18PM -0600, Ben Reubenstein wrote:> Thx for the quick reply and the excellent library. I am trying to > import the .vcf files into Outlook 2002 (gag!) and I think my issueOuch!> might be that it wants version 2.1 cards :( I just installed > Thunderbird thinking it would accept VCF files to test, but to my > surprise it doesn''t. > > The vcf file saved by Outlook uses this format: > > ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Address Line 1 =0D=0AAddress Line > 2 =0D=0AAddress Line 3;City;St;11111;Uni> ted States of AmericaI was afraid of that. I didn''t think 2.1 was so popular when I started the project. My underlying decoder/encoder supports much of 2.1, tries to preserve 2.1 fields it found, but its encoding is 3.0 specific (though much of 3.0 is the same as 2.1). I don''t have the time to do a v30 -> v21 converter, though I think it could be done with the Field APIs, and if you were willing to do it I would be very, very happy to take the patches... Basically, you would have to go through each field, and then change its format to what 3.0 expects. ADR;type=WORK:;;Address Line 1 \nAddress Line 2 \nAddress Line 3;City;St;11111;Uni ted States of America Would be what your adr looks like before conversion. There probably aren''t that many fields that need conversion, a lot of basic stuff is the same. The advantage of the conversion approach is you can use the nice encoding APIs in the Maker, and then go through and tweak the fields to reencode them later. The other approach is to not use Maker#add_address, and manually create/add the Field with the correct values. Set encoding=quoted-printable, qp encode the string you put in as the value, etc. Take a look at the samples, there are a few v21 samples that show how to do a limited bit of work with 2.1 cards. Sorry I don''t have a better answer. I guess it depends on how badly you need to do this. If you want to add v21 support, I would be happy to advise. Btw, this coming thursday I''ll be on vacation, and away from email for 10 days. As a totally different approach, if you could find a command line utility that did format conversion, maybe just shelling out to it would be the pragmatic thing to do. Anyhow, let me know what approach you take and I''ll try and help. Sam
Hi Sam ~ Microsoft loves standards don''t they? I took the VCF files I generated and they work perfectly except where I need them to. On the Mac they are perfect with the address book. Currently I am pretty busy, but I think I might invest some time looking at your source and potentially massaging certain items back to the 2.1. I will be sure to send you anything if I think it isn''t too duct tapped. Have a great time on vacation! Thx, Ben On 4/11/06, Sam Roberts <sroberts at uniserve.com> wrote:> On Tue, Apr 11, 2006 at 01:38:18PM -0600, Ben Reubenstein wrote: > > Thx for the quick reply and the excellent library. I am trying to > > import the .vcf files into Outlook 2002 (gag!) and I think my issue > > Ouch! > > > might be that it wants version 2.1 cards :( I just installed > > Thunderbird thinking it would accept VCF files to test, but to my > > surprise it doesn''t. > > > > The vcf file saved by Outlook uses this format: > > > > ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;Address Line 1 =0D=0AAddress Line > > 2 =0D=0AAddress Line 3;City;St;11111;Uni> > ted States of America > > I was afraid of that. I didn''t think 2.1 was so popular when I started > the project. > > My underlying decoder/encoder supports much of 2.1, tries to preserve > 2.1 fields it found, but its encoding is 3.0 specific (though much of > 3.0 is the same as 2.1). I don''t have the time to do a v30 -> v21 > converter, though I think it could be done with the Field APIs, and if > you were willing to do it I would be very, very happy to take the > patches... > > Basically, you would have to go through each field, and then change its > format to what 3.0 expects. > > ADR;type=WORK:;;Address Line 1 \nAddress Line > 2 \nAddress Line 3;City;St;11111;Uni > ted States of America > > Would be what your adr looks like before conversion. There probably > aren''t that many fields that need conversion, a lot of basic stuff is > the same. > > The advantage of the conversion approach is you can use the nice > encoding APIs in the Maker, and then go through and tweak the fields to > reencode them later. > > The other approach is to not use Maker#add_address, and manually > create/add the Field with the correct values. Set > encoding=quoted-printable, qp encode the string you put in as the value, > etc. > > Take a look at the samples, there are a few v21 samples that show how to > do a limited bit of work with 2.1 cards. > > Sorry I don''t have a better answer. I guess it depends on how badly you > need to do this. If you want to add v21 support, I would be happy to > advise. Btw, this coming thursday I''ll be on vacation, and away from > email for 10 days. > > As a totally different approach, if you could find a command line > utility that did format conversion, maybe just shelling out to it would > be the pragmatic thing to do. > > Anyhow, let me know what approach you take and I''ll try and help. > > Sam > > _______________________________________________ > Vpim-talk mailing list > Vpim-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/vpim-talk >-- Ben Reubenstein http://www.benr75.com
On Wed, Apr 12, 2006 at 11:06:54AM -0600, Ben Reubenstein wrote:> Microsoft loves standards don''t they? I took the VCF files I:-)> generated and they work perfectly except where I need them to. On the > Mac they are perfect with the address book. Currently I am pretty > busy, but I think I might invest some time looking at your source and > potentially massaging certain items back to the 2.1. I will be sure > to send you anything if I think it isn''t too duct tapped.Even if it is a hack, I can put it in as an example, and maybe others can benefit from it. Cheers, Sam