How to export Address Book content as Unicode with applescript?

Hello,
I have a problem for exporting address book content. I'd like to export "My Card" to a vcf file and use another application to read it. So I have the following applescript:
*+tell application "Finder"+*
*+set theFolder to folder "TemporaryItems" of folder "Caches" of folder "Library" of home+*
*+end tell+*
*+tell application "Address Book"+*
*+set theVcard to (vcard of my card) as Unicode text+*
*+set theFile to (theFolder as text) & "myCard.vcf"+*
*+set theFileHandle to open for access theFile with write permission+*
*+-- write (ASCII character of 254) to theFileHandle+*
*+-- write (ASCII character of 255) to theFileHandle+*
*+write theVcard to theFileHandle+*
*+close access theFileHandle+*
*+end tell+*
OK, now the problem is that if "My Card" has any double-byte characters like Chinese or Arabic, the output file will just hold some question marks ("??"). The code works in Tiger but not Leopard. (Add char 254 and 255 just to make it a UTF16-BE file. So it doesn't really change the result of this script.)
I started digging and guess here is the reason: in the following statement the "vcard of my card" will always return plain text:
+*set theVcard to (vcard of my card) as Unicode text*+
I got this clue from the help of ScriptEditor:
+*vcard (text, r/o) : Person information in vCard format, this always returns a card in version 3.0 format.*+
But in Tiger, you can see:
+*vcard (Unicode text, r/o) : Person information in vCard format, this always returns a card in version 3.0 format.*+
Any workaround to solve this problem?
(And if this is not the right place to ask such question, please just let me know.)
Thanks a lot!
Calvin

Hello Calvin,
Since your code works under OSX10.4 and fails under OSX10.5, the cause would be the change made in AppleScript 2.0.
Try -
write theVcard as Unicode text to theFileHandle
instead of -
write theVcard to theFileHandle
The read/write commands in AS 2.0 have been change so that they will always interpret the text in system's primary encoding if 'as Unicode text' is not specified in commands' parameter.
cf.
http://developer.apple.com/releasenotes/AppleScript/RN-AppleScript/index.html
Unicode Support
http://developer.apple.com/documentation/AppleScript/Conceptual/AppleScriptLangG uide/
pp. 151-153, 168-169 (of pdf version)
Commands Reference > read, write
Hope this may help,
H

Similar Messages

  • How to export Address Book to FileMaker Pro?

    How to export Address Book to FileMaker Pro so mailing labels can be printed.
    FileMaker Pro does a better job at a miniature address book.
    Thanks!

    @GeorgeBetty,   I asume that Address Book's built in print functionality doesn't meet your needs. correct?
    https://discussions.apple.com/thread/2670577
    The Soliant_vCard_Import_v1.1.fp7 file will come in handy someday... I've got that saved.  Thanks BDAqua!

  • How to Export Address Book contacts as CSV file for Gmail?

    Hi
    I wish to export some of my Address Book contacts towards Gmail (which i use through the web interface for now) but I don't want to export vcards as i don't trust big brother Google with all the other data (snail mail, phone numbers, birthdays, etc).
    I have tried to do the export through Address Book but found no CSV export option.
    I've searched the forum for an answer, but to no avail. Some other (paying) websites claim to offer solutions but the "pay before you see" deters me from using them.
    Any tip on how to do this would be greatly appreciated. Scripts and software also welcome, if shareware/freeware.
    Cheers,
    FMN

    Thanks for your answer, but gmail's help specifically states one can import contacts in CSV format and i was looking for a simple batch solution.
    Here is a link to the relevant gmail page (might be in French - am not a "Froguette" for nothing ;)) about importing:
    <http://mail.google.com/support/bin/topic.py?topic=28647>
    and the one about importing addresses as CSV files:
    <http://mail.google.com/support/bin/answer.py?hl=fr&answer=12119>)
    So my question still stands.
    FMN
    Message was edited by: FroguetteMiNote - wrong link corrected
    Message was edited by: FroguetteMiNote

  • How to export address book from ibook g4 to iMac Intel?

    Hi, can anyone advise what I need to do to export the contacts in the address book of an ibook g4 running OS 10.4.11 to a new iMac 3.2 GHz Intel iCore 3 running OS 10.6.7? Thank you for your help.

    Hi - on the iBook launch Address Book, click on one of your contacts and then click Command+A to select all contacts. In the Address Book File menu select Export>vCards and save them to disk. If the two Macs are on the same network just copy them across to the iMac, launch Address Book on the iMac and go to File>Import and import the vCards file you copied over. If the Macs aren't on a network copy the vCards file across on a USB stick or email them to yourself.

  • How to export address book contacts to numbers sheet

    I am looking for a way to export my address book contacts from a specific group to a Numbers spreadsheet. Can someone help me with that? I would think it should be a simple task, but I can't seem to find any help for that kind of an operation.
    Thanks in advance for any help.

    select the contacts
    copy,
    switch to Numbers
    paste
    You should also make sure, in System Preferences, that Numbers is allowed to access Contact information in the "Security & Privacy" panel:

  • Does anyone know how to export Address Book entries into Excel?

    I need to send someone address book information, and would like to send it in Excel vs. creating a pdf. This way I can remove information categories they don't need (and they'd prefer to get it in Excel). Does anyone have any suggestions as to how I can do this?
    Thanks!
    joanne

    Take a look at this video from Mark Spencer.  It explains the basics of a C4D/Motion workflow.  Again, as Adam states, this does not bring in 3D models from C4D.
    http://provideocoalition.com/index.php/mspencer/cinema4d_finally_brings_3d_to_mo tion/

  • Is there a trick to forcing Address Book to update/sync with Google?

    I cannot figure out how to force Address Book to update / sync with Google. Every time I go into Address Book preferences and check the box for Google synchronization and type in my information it shows that it is connecting. But the contacts do not update. Then when I close Address Book and open up preferences again, the checkmark for Google synchronization is gone. This happens on my Mac Pro tower and also on my MacBook Air -- both are running OSX 10.6.4. Any ideas?

    Try opening up iSync in Applications. Go into preferences and make sure the "Show in Menu Bar" option is selected.
    Then you can click iSync in the menu bar and tell it to Sync Now. Might help?

  • How to move Mail and Address book content from 10.3 emac to 10.5 iMac

    How do I move Mail and Address book content from my old 10.3 emac to my new 10.5 Leopard iMac directly, or do I have to move the names etc, one by one?
    Richard

    I cannot find a migration assistant. I have copied the Mail and Address Book applications over from 10.3 to 10.5 and tried using mailboxes import, but 10.5 Mail will not accept any of the options. The same for address book. Can you give more specific instructions?
    The applications, Mail and Address Book, don't actually store your data in the application. So, moving the applications over to your new computer will have no useful effect and could be detrimental if you replaced the newer versions with the old.
    Migration Assistant is in you Utilities folder and should have asked to be run during the installation.
    Your Mail data is stored in yourUserName/Library/Mail. The Address Book data is stored in yourUserName/Library/Application Support/AddressBook. If your new installation is blank with no data, you can actually replace those directories on the 10.5 version with the old. For Mail, you also have to get the com.apple.mail.plist file from your old username/Library/Preferences/ folder and put it in the new 10.5 folder of the same name. Once that is done, when you open Mail and Address Book, they will update the data to the new format.
    Migration Assistant will do all of this for you.
    EDIT: Based on roam's comments, you may have to move the Mail manually. You can also just bring the Mail directory over to the 10.5 machine and use Mail's Import command to get all the mail out of the old Mail directory.
    Message was edited by: Barney-15E

  • How do I Export Address Book data?

    Is there anyway to insert Address Book data into other (non-Apple) applications, e.g. Word?
    I want to send out some letters and I would like each letter to have the recipiants address at the top of the letter. Even if I could export the data to Excel first would be OK but I only seem to be able to export vCards from Address Book and Excel (nor Word) can read them?
    Any help would be appreciated.
    Thanks,

    Yink,
    you can use some third-party applications to export Address Book data as plain text files (e.g., csv) which you should then be able to import without any problems in Excel and the like.
    Some options are:
    • Export Addresses from Mail Scripts
    http://homepage.mac.com/aamann/
    • Address Book Exporter
    http://www.gwenhiver.net/address-book-exporter.html
    • Export Address Book
    http://software.dibomedia.de/ExportAddressBook
    Andreas

  • Merging Tiger Address book contents with ML Contacts

    Hi,
    Since late December I've been the proud owner of a (gorgeous new) 27" iMac. This has replaced my old G5 workhorse which is running Tiger. The two are running side-by-side until I get everything migrated and converted.
    For the past couple of months I've been adding new contacts, as they come in, to 'Contacts' on the iMac. However I have to bring over all my old contacts from Address Book on Tiger.
    With hindsight I guess I shouldn't have done it this way but attempeted to bring them all over on day one. But I'm here now and I have lots and lots on Address book in Tiger and some in Contacts on Mountain Lion. I need both sets.
    Any help as to how I can merge the two onto Contacts on the iMac will be much appreciated.
    (If it makes any difference I don't use mail.app by the way but my Contacts are synced with my iPad).
    Bob.

    On the Tiger machine, export the contacts as vCards. If you have notes, make sure to select the option to save the notes on export--I don't know if Tiger Address Book had those options. It should produce one vCard with all contacts in it, but it may make one for every card. I can't remember what Tiger will do.
    Back up Contacts on the new Mac using File>Export>Contacts Archive.
    Move them over to the new Mac and double-click the vCard to import them into Contacts. It should not ask you to replace them, but if it does, cancel the import.

  • Export Address Book into Outlook

    How do you export Address Book to use in Outlook?

    You connect the iPhone to iTunes, select Outlook as to where you want to sync contacts, and calendar if you want, and then sync. The only thing you need to do is make sure if the Outlook on the computer is completely empty, put in a unique contact in Outlook to force the merge option to come up. See this support document http://support.apple.com/kb/HT1296

  • How to copy address book archive to a dvd

    Recently synced iphone to imac and lost all contacts (aargh!!!!). Itunes was set for automatic backup, so the backup contact file was also blank. Found a two year old copy of my contacts. I have now manually inputted them all. I created an addressbook archive file. However, I can not find out how to  (1) copy or burn this archive to a dvd so I can restore from it if needed again and (2) how to print a copy of the entire addressbook>
    Please help!!
    P.S.
    I read through a lot of previous posts and saw where this iphone syncing and deleting contact lists is not a new problem. It also is not a function of my being a neo-luddite. Many others have had this happen. Is there some type of fix in the works to deter this from continuing to happen?
    Thanks,
    Ralph

    Also found how to copy Address Book, as well as all others files on my computer.
    The answer is to open Address Book.
    Under FILE menu>Export>Address Book Archive
    at prompt, Save to which ever location you wish on your computer ( I chose Documents). This will create an archive of your contact list with that date. Archive after anytime you change or add an address card. If saved to the same location on the same computer, prompt will ask if you want to Replace current>OK. If you archived on different days, you will create a new file with different date. You can throw away previously dated file or save as a backup.
    To copy this file and all other files on my computer, I had to download the latest copy of Backup (v3.2) from the Apple downloads page under Apple support. This provides an installer to create a back up iDisk. I installed Backup>( it creates an Umbrella icon on my desktop)>followed the instructions to create a backup>program has standard backup protocols or you can customize.
    I chose to backup my Home folders to a CD/DVD. System will tell you the size of the file and how many CD's or DVD's you will need. Select Burn.
    Voila!!!!
    I now have a DVD that contains all of the files in my Home folder (including the Address Book archive). This DVD will allow me to restore files to my computer, if I accidentally erase it again. Note that this method will not allow you to backup the entire startup, only files. You must use an external drive or Time Machine to create a rebootable copy of the operating system.
    Hope this helps others.

  • How to migrate Address book and Stickies without using Migration Assistant

    Can anyone direct me on how I can copy over my address book and all of my stickies from one OSx HDD to a new HDD?
    I noticed when I went into the Migration Assistant, that some of the options were greyed out such as "Other Data" in my profile and seemed to be pretty huge. So I don't want to use the Migration Assistant because I did a clean install on this machine and I am worried about migrating garbage from my old installation.
    Thanks.

    Hi
    With Address Book you can simply open the application, go to File/Export/Address Book Archive, and save. To import on the target Mac/Installation go to File/Import/Address Book Archive.
    If the system has become a non bootable system but you can mount the drive then simply go to the relevant users home folder ~/Library/Application Support/ and copy the Address Book folder to the same location on the target Mac/Installation.
    For Stickies data simple go to the relevant users home folder ~/Library/ and copy the file entitled StickiesDatabase to the same location on the target Mac/Installation.

  • How to sync Address Book, iCal, Bookmarks

    How to sync Address Book, iCal, Bookmarks between my iMac and Macbook?

    {quote:title=Julian Wright wrote:}Do you expect everything to be free?{quote}
    Geez, ya big meanie, give the guy a break. Not everyone wants to spend $50 on a syncing solution! He just asked a question, and you heap attitude on him about his finances. Not your business!
    5480, syncing that information between two Macs is both easy and tricky at the same time. It’s easy because you really can just copy the files back and forth. But it can get tricky if, for instance, you were to change information on both sides. Then you’ve got two different versions! The general solution to this is to be pretty careful about only changing data on one side at a time. If you add some contacts on one side, don’t go working in Address Book on the other side until you’ve copied the new info over.
    “Exporting” the data, burning to CD, and then importing it on the other Mac would be a total pain in the ***, though. Much too time consuming. What you need to do, if you don’t want to pay for a solution (I didn’t for ages), is just learn to hook your computers together on a network, and copy over the relevant files directly (no exporting, no CD burning). Address Book, iCal and bookmarks data is all stored in folders in your Library folder. You just copy it over! Be sure to quit the applications before moving the data.
    Where exactly are these files, you say? How do you network? Figuring out the details is your homework assignment, but the method works. Good luck!

  • How to set up an address book and make labels with numbers or pages?

    How do you set up an address book and make labels with numbers or pages?

    Create an Apple ID - My Apple ID

Maybe you are looking for

  • Grey Screen and Spinning Circle When Trying to open a PDF from a website

    I tried to view a pdf from a website and a little window popped up. At the time i thought it was to save the pdf but i guess it was in fact asking me to find the adobe acrobat program. I quit out of it and now keep getting the grey screen and spinnin

  • Link Webi Report to External URL using URL contained in Dim Object

    I am trying to create a link in my WebI report to an external URL which is stored in a Dimension object. The object is simply a string format which contains a link to a Lotus Notes database Example: Notes:///CA2573920000079B/0B4D8972EDD5DE7CCA2571090

  • APEX 2.2.1 upgrade - htmldb_collection.create_collection_from_query problem

    We have recently upgraded a production application from 1.6 to 2.2.1 and have found a problem creating a collection from a query in a before header process. The page no longer displays and we eventually get the standard http request failed message af

  • Want code for reset

    Hello Gurus.. I have a page that has the Create button and Reset button...I want to reset the values of my fields and i want to write a code for it.So please help with the code....

  • Cloning fails in db_clone.pl...

    I am trying to clone a windows db to a windows server with just files loaded using Enterprise Manager. We continue to get the following error during the destination preparation step . Error in closing SQL_SCRIPT : at C:\OracleHomes\agent10g/sysman/ad