Code Monkey home page Code Monkey logo

Comments (10)

alexzhirkevich avatar alexzhirkevich commented on July 19, 2024 1

Try another encoding, for ex. utf-16

from custom-qr-generator.

alexzhirkevich avatar alexzhirkevich commented on July 19, 2024 1

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

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024 1

OH, I founded the problem, its about VERSION:4.0, 3.0 is work, ios phonebook can't read correctly with 4.0 Vcard

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024 1

Thank you for helping me <3

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024

thank you for helping

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024

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")
    }
}

}

from custom-qr-generator.

alexzhirkevich avatar alexzhirkevich commented on July 19, 2024

Charset is passed as a hint for zxing lib. Tbh i can’t do anything here. What name are u trying to encode?

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024

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)
)
}

from custom-qr-generator.

alexzhirkevich avatar alexzhirkevich commented on July 19, 2024

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:

private val initialMatrix = Encoder.encode(
data.encode(),
with(options.errorCorrectionLevel) {
if (this == QrErrorCorrectionLevel.Auto)
fit(options.logo, options.codeShape).lvl
else lvl
},
charset?.let {
mapOf(EncodeHintType.CHARACTER_SET to it)
})

Mb ios phonebook is not ready for vcard v4 :). Did you try UTF-16?

from custom-qr-generator.

huyngo1801 avatar huyngo1801 commented on July 19, 2024

oh, its work in that website (utf 8), Why i used your base Vcard its show normally but mine

from custom-qr-generator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.