From e66ec05ba616aa2e932491a90675babd1caa7fda Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 3 Feb 2018 23:47:45 +0100 Subject: [PATCH] add the info declaring quoted-printable at exported vcf when necessary --- .../com/simplemobiletools/contacts/helpers/VcfExporter.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt index 052447f0..85fa0bec 100644 --- a/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/contacts/helpers/VcfExporter.kt @@ -36,7 +36,7 @@ class VcfExporter { for (contact in contacts) { out.writeLn(BEGIN_VCARD) out.writeLn(VERSION_2_1) - out.writeLn("$N:${getNames(contact)}") + out.writeLn("$N${getNames(contact)}") contact.phoneNumbers.forEach { out.writeLn("$TEL;${getPhoneNumberLabel(it.type)}:${it.value}") @@ -92,6 +92,7 @@ class VcfExporter { } private fun getNames(contact: Contact): String { + var result = "" var firstName = contact.firstName var surName = contact.surname var middleName = contact.middleName @@ -102,9 +103,10 @@ class VcfExporter { firstName = QuotedPrintable.encode(firstName) surName = QuotedPrintable.encode(surName) middleName = QuotedPrintable.encode(middleName) + result += ";CHARSET=UTF-8;ENCODING=QUOTED-PRINTABLE" } - return "$surName;$firstName;$middleName;;" + return "$result:$surName;$firstName;$middleName;;" } private fun getPhoneNumberLabel(type: Int) = when (type) {