pinoaffe / org-vcard

Export and import vCards from within GNU Emacs' Org mode.
63 stars 7 forks source link

Properties with a charset #5

Closed sg2002 closed 10 years ago

sg2002 commented 10 years ago

Hello. This project has great potential, but in the current state it's unusable for me, because of a couple of issues. The first is unicode support. It seems that if a property is declared as having a charset, it's just skipped. Here's an example vcard:

BEGIN:VCARD VERSION:2.1 N;CHARSET=UTF-8:Пупкин;Василий TEL;HOME:+74951234568 TEL;WORK:+74951234569 TEL;FAX:+74951234560 TEL;CELL:+74951234567 TEL:+74951234561 ADR;HOME;CHARSET=UTF-8:;;Кремль;;;; END:VCARD

Since both address and name fields are in unicode, they do not appear in the conversion output.

Also, some interactive hints would be nice, I had to look into the source code to understand what should be entered in Source and Destination fields during the import.

flexibeast commented 10 years ago

The problem isn't that the values of the fields are in UTF-8; the problem is the presence of the CHARSET property modifier. The canonicalisation process currently doesn't remove that, leaving a property "N;CHARSET=UTF-8" that doesn't exist in any mappings, thus causing it to get skipped. You can verify this for yourself by removing ";CHARSET=UTF-8" from any line that has it, then running org-vcard-import on the result.

At this point i want to focus on supporting only UTF-8 and ASCII - vCard 4.0 mandates UTF-8 overall, vCard 2.1 mandates ASCII overall, and i'm not yet clear whether vCard 3.0 mandates an encoding or not. In terms of importing, a quick hack that might work would be to discard modifiers like CHARSET=UTF-8; but in terms of exporting to vCard 2.1, output is currently encoded as ASCII (as per the standard), but obviously being able to specify and output a non-ASCII CHARSET for individual properties is critical.

So, thanks for bringing this to my attention - i'll have to give some thought to how to handle and fix it.

Finally, as with many other interactive commands, you can get a list of possible completions by pressing TAB at each prompt. i will certainly update the documentation to note this!

flexibeast commented 10 years ago

i also just noticed that because your example vCard doesn't provide an FN property, an empty heading gets created on import. i've created issue #8 for this.

sg2002 commented 10 years ago

I do not get interactive options for source and destination types. Actually, I even get a message: completion--some: Invalid function: (buffer region subtree)

Didn't see this before, since I had icicles on.

flexibeast commented 10 years ago

That's odd. i just double-checked what happens when i run org-vcard-import interactively, and pressing TAB at the "Source: " prompt gives me a list of possible completions.

What version of Emacs are you running?

sg2002 commented 10 years ago

I use 24.3.1 on Windows. Tried with emacs -q, same thing.

flexibeast commented 10 years ago

Okay. i'll try setting up Emacs 24.3.1 and org-vcard in a Win 7 VM and see if i can reproduce the problem. (i'm on Debian Wheezy.)

flexibeast commented 10 years ago

i've reproduced the TAB-doesn't-provide-possible-completions issue on Emacs 24.3 on Win 7; i've opened issue #12 for this.

flexibeast commented 10 years ago

i've made changes to address both issue #8 and issue #12; could you please verify that those issues are fixed for you?

flexibeast commented 10 years ago

i've just made some changes to handle the CHARSET property modifier; could you please test if they work for you?

sg2002 commented 10 years ago

Worked fine with 4.0, tested with my current contacts app. But I just noticed something - my phone sync program won't support 4.0 vcards. Can we get maybe a variable to enable utf8 for all strings in 2.1 export?

flexibeast commented 10 years ago

Well, the code i added was simply for handling imports, and in particular, handling non-ASCII data for vCard 2.1. vCard 4.0 and 3.0 don't have the CHARSET modifier, so simply ignoring that modifier when it's (incorrectly) present was enough to make import work for those versions; but i've also added code to utilise the CHARSET modifier when it's used for 2.1. So could you please try importing a version 2.1 vCard with a CHARSET modifier for UTF-8 values, such as the one you provided above? If that works for you, i'll close this issue.

In any event, yes, i'll definitely add functionality to be able to specify a character set for values when exporting to vCard 2.1 - good suggestion, thanks! You might like to subscribe to issue #13, which i've opened for this.

sg2002 commented 10 years ago

Yes, importing works fine.

flexibeast commented 10 years ago

Thanks! Closed.