Closed fts11259375 closed 1 year ago
Hello @fts11259375,
Thank you for you using vcard4
, and for your valuable contribution to the vcard4 community (this issue).
This library is dedicated to strictly adhering to the vCard version 4.0 specification (RFC6350). This means that we stay true to the guidelines set forth in the official specification without introducing any additional features or deviating from it.
Allow me to provide some brief historical context to this character set issue. In early versions of vcards, specifically version 2.1 and earlier, the default character set of vcards was ASCII, but this could be overridden in specific properties using the "CHARSET" property parameter (very much like what you're doing).
However, for later versions, 3.0 and 4.0, the charset for vCard is UTF-8. There is no way to override this and it is invalid to specify a value other than "UTF-8" in a "charset" MIME parameter (see section 3.1 of the RFC).
In fact, in version 4.0 vCards, the "CHARSET" property parameter is intentionally removed from the vCard specification (see Appendix A2 of the RFC). This was also the case for vCard 3.0.
In conclusion, this feature WILL NOT be included in the vcard4 library, because the library remains true to RFC 6350 and its extensions.
Let me provide some insight into the issue you're currently facing. It seems that the root of the problem might stem from the vCard version compatibility.
It's worth noting that the most widely used vCard version is vCard 2.1. Considering the symptoms you're encountering, it's possible that the device you're using to test your code doesn't support vCard 4.0 and might be limited to vCard 2.1 compatibility.
If we take a closer look at the historical context I provided in the earlier comment, the pattern you're employing (such as adding CHARSET to properties) was common in vCard 2.1. This suggests that if your device only responds positively to this approach, it likely supports only vCard 2.1.
Given this, I'd recommend considering two options. First, you could explore using a different device for testing, one that supports vCard 4.0. Alternatively, you might want to consider utilizing a library that generates vCard 2.1 vcards. Either approach should help align your code and device compatibility.
Feel free to reach out if you have any questions or need further assistance.
Thank you for your answer. It may be that the problem I encountered is caused by the phone manufacturer not following the specifications. On iPhones, if there is no "CHARSET" label, Chinese characters will display as garbled text. This is true for both vCard 3.0 and 4.0 versions. If the "CHARSET" label is included, Chinese characters can be displayed normally.
I have also encountered another issue. When using base64-formatted URIType in PhotoProperty, if the string "data:image/png;base64," is added before it, the photo cannot be displayed when imported into the phone. However, if the string "data:image/png;base64," is removed, the photo can be displayed on the phone but cannot be used in this format within URIType.
------------------ 原始邮件 ------------------ 发件人: "kelseykm/vcard4" @.>; 发送时间: 2023年8月8日(星期二) 晚上9:29 @.>; @.**@.>; 主题: Re: [kelseykm/vcard4] It would be helpful to have charset support included, even if it's added to AnyParameter. (Issue #18)
Let me provide some insight into the issue you're currently facing. It seems that the root of the problem might stem from the vCard version compatibility.
It's worth noting that the most widely used vCard version is vCard 2.1. Considering the symptoms you're encountering, it's possible that the device you're using to test your code doesn't support vCard 4.0 and might be limited to vCard 2.1 compatibility.
If we take a closer look at the historical context I provided in the earlier comment, the pattern you're employing (such as adding CHARSET to properties) was common in vCard 2.1. This suggests that if your device only responds positively to this approach, it likely supports only vCard 2.1.
Given this, I'd recommend considering two options. First, you could explore using a different device for testing, one that supports vCard 4.0. Alternatively, you might want to consider utilizing a library that generates vCard 2.1 vcards. Either approach should help align your code and device compatibility.
Feel free to reach out if you have any questions or need further assistance.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I believe both issues stem from the same root cause.
Many manufacturers seem to deviate from the vCard specification. I'm convinced that some don't even verify the vCard version before parsing it. I think in pursuit of the 'Robustness Principle,' they often adopt a "mongrel" parser that handles different vCard versions, but leaning heavily towards vCard 2.1 parsing functionalities
In order to support other languages, I need to add charset to the vCard and generate the vCard string as follows:
I haven't been able to find a method that supports charset, so I currently manually add CHARSET to paramRegExp in AnyParameter and rebuild. It would be helpful to have charset support included, even if it's added to AnyParameter.