jowave/vcard2to3

UTF8 Encoded Nickname isn't detected

Bip901 opened this issue · 4 comments

Describe the bug
X-ANDROID-CUSTOM:vnd.android.cursor.item/nickname is not detected properly if CHARSET=UTF-8 is present, which is the case when exporting from my Android 13 Samsung device.

To Reproduce
Steps to reproduce the behavior:

  1. Prepare input files 'utf8-nickname-test.txt' (extension .txt because GitHub doesn't allow .vcf uploads)
  2. Run script 'vcard2to3.py'
  3. Observe that the property is not replaced with NICKNAME.
  4. Expected result: utf8-nickname-test-expected.txt

Additional context
I've already implemented a solution and I'd like to get permission to push it to a separate branch.
Alternatively, feel free to make the changes yourself in vcard2to3.py line 152:

'^X-ANDROID-CUSTOM(;CHARSET=UTF-8)?:vnd.android.cursor.item/nickname;([^;]+);.*'), 'NICKNAME\\1:\\2'))

This allows an optional CHARSET=UTF-8 field, and persists it after conversion.

Thanks for your suggestion.
I have added it, but changed it to not persist the CHARSET=UTF-8 parameter, because the vCard 3.0 does not support charset parameters (in section 5).

Awesome, cheers! 🍻

Note that CHARSET=UTF-8 is persisted in the N and FN fields - you might want to remove those, too.

Yeah, would be more conforming to vCard 3.0.