Problems with Unicode text in OSX (Mac)


<< Why do two VB TLBs get in ...
Back to Portfolio FAQ index
Main Menu and Toolbar (v7 ... >>

This was flagged by a question in alt.comp.lang.applescript from a Portfolio user. He noted:

tell application "Extensis Portfolio 6.1"
   --This line works:
   set field "keywords" of every record of selection of front gallery to "dragon"
   --This line does not work:
   set field "keywords" of every record of selection of front gallery to sValue
end tell

Anyway, it transpires that somewhere in the move to OSX (10.0 or later not known) some things now return text as Unicode - including dialogs. Unhelpfully, AppleScript fails to differentiate between these data types - regarding them all as text/string type - and the error you get is "Portfolio got an error: Some data was the wrong type".

Thus until the Portfolio AS interface supports both UTF-8 (Mac Roman) and UTF-16 (Unicode) text - you may need to 'clean' dialog response text en route to Portfolio. Use the handler demonstrated below:

tell application "Extensis Portfolio 6.1"
   set sValue to text returned of (display dialog "Keyword value?" default answer "Cat")
   set sValue to my cleanText(sValue)
   set field "keywords" of every record of selection of front gallery to sValue
end tell

on cleanText(sValue)
   tell application "Finder"
      set sValue to item 1 of ((sValue as record) as list)
   end tell
end cleanText

[above code tested Portfolio 6.1.3, SD 3.0.8, OS 10.3.2]

The writing of strings returned by a dialog is just one cause - there may be others. The giveaway is if you're sure you're using a string but are getting an error message about 'wrong type' of data.



Question: Problems with Unicode text in OSX (Mac) [FAQ00353.htm]
Last Update:- 01 June 2006


<< Why do two VB TLBs get in ...
Back to Portfolio FAQ index
Main Menu and Toolbar (v7 ... >>

Quick Search of PortfolioFAQ (word, words or phase): or try the Advanced Search

User-to-User Forums  |  Report error/typo/broken link  |  Request new topic  |  Ask a question

Site and articles © Mark Anderson 2001-2007 - Visit my home page


This FAQ is created and maintained using
Friday logo
Friday - The Automatic FAQ Maker