KAddressBook: Fix import encoding for vCard v4.

Signed-off-by: Mavridis Philippe <mavridisf@gmail.com>
pull/130/head
Mavridis Philippe 5 months ago
parent 6f4e770e24
commit 12f0bfb59c
No known key found for this signature in database
GPG Key ID: F8D2D7E2F989A494

@ -239,9 +239,22 @@ TDEABC::AddresseeList VCardXXPort::importContacts( const TQString& ) const
// With version 3.0, vCards are encoded with UTF-8 by default. Otherwise, use fromLatin1() // With version 3.0, vCards are encoded with UTF-8 by default. Otherwise, use fromLatin1()
// and hope that are fields are encoded correctly. // and hope that are fields are encoded correctly.
if ( TQString::fromLatin1( rawData ).lower().contains( "version:3.0" ) ) { bool useUtf8;
TQString tmp = TQString::fromLatin1(rawData).lower();
int ver = tmp.find("version:");
if (ver == -1) {
// no version info, assume utf8
useUtf8 = true;
}
else {
float vCardVersion = tmp.mid(ver + 8, tmp.find("\n", ver)).toFloat();
useUtf8 = (vCardVersion >= 3.0);
}
if (useUtf8) {
vCardText = TQString::fromUtf8( rawData ); vCardText = TQString::fromUtf8( rawData );
} else { }
else {
vCardText = TQString::fromLatin1( rawData ); vCardText = TQString::fromLatin1( rawData );
} }
addrList += parseVCard( vCardText ); addrList += parseVCard( vCardText );

Loading…
Cancel
Save