Question

I've got a vcf file from Google's contacts export feature. It was encoded with UTF-8, but my WinMobile telephone expects win1251 characters to import into contactbook. I recoded it into win1251 and did try to parse the file using vObject library. What I got as a result was a mix of fields some of which were correctly encoded into Unicode, and some were replaced by "?????" text. For example I include a prettyPrint of such a contact:

 VCARD
    TEL: +7812000000
    params for  TEL:
       aKey TYPE [u'CELL']
    TEL: +7921000000
    params for  TEL:
       aKey TYPE [u'HOME']
    URL: http\://www.diamantstroy.spb.ru
    X-ABLABEL: _$!<HomePage>!$_
    N:  Alexei  ??????? 
    VERSION: 3.0
    ORG: [u'\u041e\u041e\u041e \u0414\u0438\u0430\u043c\u0430\u043d\u0442-\u0421\u0442\u0440\u043e\u0439-\u0421\u0435\u0440\u0432\u0438\u0441']
    FN: Alexei ???????

What I cannot find is a place in the source-code where I should apply some sort of encode()/decode() patch to fit my needs. Could someone help me?

No correct solution

OTHER TIPS

Make sure your input is unicode when you pass it to readOne (or whatever parsing function you are using). If you want to go back to Windows-1251 coding, after you parse the vcard use result.encode('cp1251') or codecs.open(filename, 'w', 'cp1251').write(result).

It is a little confusing what flow you are going thru. Are you doing phone -> google -> code, or since you use the word expects, are you doing google -> code -> phone?

This answer may help with conversions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top