Closed huyngo1801 closed 1 year ago
Try another encoding, for ex. utf-16
thank you for helping
I want to create new VCard(4.0) and the charset is not working.
fun interface NewQrData : QrData {
data class VCard(
val id: String? = null,
val full_name: String? = null,
val phoneNumber: String? = null,
val email: String? = null,
val gender: String? = null,
val lastUpdated: Long? = null,
val timeZone: String? = null,
val company: String? = null,
val note: String? = null,
) : QrData {
override fun encode(): String = buildString {
append("BEGIN:VCARD\n")
append("VERSION:4.0\n")
if (full_name != null) {
append("FN:${full_name}\n")
append("KIND:individual\n")
append("N:${full_name}\n")
}
if (id != null) {
append("UID:$id\n")
}
if (phoneNumber != null)
append("TEL:${phoneNumber}\n")
if (email != null)
append("EMAIL:${email}\n")
if (gender != null) {
if (gender == Contains.MALE)
append("GENDER:M\n")
else
append("GENDER:FM\n")
}
if (timeZone != null) {
append("TZ:$timeZone\n")
}
if (company != null)
append("ORG:$company\n")
if (note != null) {
append("NOTE:$note\n")
}
append("END:VCARD")
}
}
}
Charset is passed as a hint for zxing lib. Tbh i can’t do anything here. What name are u trying to encode?
I used your QRData.VCard charset still ok, but when I use NewQrData its not working
val qrCodeVCard = generateVCardUserQRCode(user)
val drawableBitmap = QrCodeDrawable( qrCodeVCard, qrLogoGolf, Charsets.UTF_8 )
private fun generateVCardUserQRCode(user: User): QrData { val timeZone = TimeZone.getDefault().id return NewQrData.VCard( id = user.id, full_name = user.full_name, phoneNumber = user.phone_number, email = user.email, gender = user.gender, lastUpdated = user.last_updated, timeZone = timeZone, note = generateNoteUserQRCode(user) ) }
It's weird, cause zxing encoder takes only result of .encode()
(no difference which QrData you pass, internal or custom). And charset is not linked to any of QrData:
Mb ios phonebook is not ready for vcard v4 :). Did you try UTF-16?
Hm, your implementation of vcard is really broken on ios. Try this website. It decodes your vcard normally. I think the reason is exactly ios phonebook
oh, its work in that website (utf 8), Why i used your base Vcard its show normally but mine
OH, I founded the problem, its about VERSION:4.0, 3.0 is work, ios phonebook can't read correctly with 4.0 Vcard
Thank you for helping me <3
I've generated an Vcard QRcode:
val drawableBitmap = QrCodeDrawable( qrCodeVCard, qrOptions, Charsets.UTF_8 ) but its not show correct Name in Vcard