Forum: Ruby Vpim::Vcard Line Breaks

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D90ef6808433e63203e15a5c2dadb0bb?d=identicon&s=25 Ben Reubenstein (Guest)
on 2006-04-11 19:31
(Received via mailing list)
Hello ~

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.

Thx in advance!

~ Ben
0ca6e5c33d7e7ff901d75ff0b13d9e1c?d=identicon&s=25 Sam Roberts (Guest)
on 2006-04-11 20:37
(Received via mailing list)
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
This topic is locked and can not be replied to.