4

I have tried to import vCard files using default Contacts app in Samsung Galaxy S6 (details here), but I am not sure about format required (vCard version supported) and Encoding to be used.

I have used Windows-1250 encoding and it worked but all the special characters were imported as ?. When using UTF-8 it failed to import completely. What is the recommended character encoding and recommended vCard format/version?

Currently my vCard file looks like this with Windows-1250 encoding:

BEGIN:VCARD
VERSION:3.0
NAME:XXXX Günzel
N:Günzel;XXXXX;;;
TEL;CELL:+XXXXXXXXX
END:VCARD
  • Have you specified the charset with your vcard records? See here for examples. – Izzy Apr 28 '15 at 11:50
  • No I did not... Should I? What is the default charset? – Vojtěch Dohnal Apr 28 '15 at 11:51
  • See my answer below :) – Izzy Apr 28 '15 at 11:58
3

That's not really an Android question, but assuming you were asking "how can I import this VCard file correctly into my Android address book": Some adjustments might be required to the VCard file. I found a specification summary in this Github issue comment:

  1. vCard 2.1 is US-ASCII by default. Individual properties can be overridden with the CHARSET= parameter.
  2. vCard 3.0 requires the mimetype to include a character set, e.g. Content-Type: text/vcard; charset=ISO-8859-1.
  3. vCard 4.0 is always UTF-8.

Giving an example for 1., taken from this article:

BEGIN:VCARD
FN;CHARSET=UTF-8:Mr. Dr. John Maurice Benjamin Doe Ph.D.\, J.D.
N;CHARSET=UTF-8:Doe;John;Maurice,Benjamin;Mr.,Dr.;Ph.D.,J.D.
END:VCARD

Further readings include RFC 6350 :)

  • 1
    That's how I would read it, yes. Not that I've played with it, though :) – Izzy Apr 28 '15 at 12:08
  • 2
    BOM? :) Have that issue quite often with SQL scripts on Oracle. Even with charset being UTF8, SQL*Plus cannot handle the BOM at the beginning of files (they must be saved as "UTF8 without BOM"). Not sure if that's the case here, though. – Izzy Apr 28 '15 at 12:37
  • 1
    As of Android N / Nougat / 7.0, the AOSP Contacts app can only import vCard 2.1 (which is also the format it exports). Any deviation from the vCard 2.1 format, including just changing the version identifier, will cause it to fail to import. – Dan May 17 '18 at 9:05
  • 1
    Thanks for that report, @Dan – but is that an experience you made on your device (which might be device specific), or is there a source you could name (which I then should include with my post)? It sounds pretty irritable that newer formats should have been abandoned in favor of an older. The opposite would be expected. – Izzy May 17 '18 at 9:07
  • 1
    @Izzy, I agree. I'm unsure if it's device- or ROM-specific and I can't find any particular source code to demonstrate it. Android is frustrating. – Dan May 17 '18 at 20:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.