• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Unicode text and class URL
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unicode text and class URL


  • Subject: Re: Unicode text and class URL
  • From: Walter Ian Kaye <email@hidden>
  • Date: Mon, 22 Mar 2004 00:52:04 -0800

At 11:52p -0800 03/21/2004, Bill Hoffman didst inscribe upon an electronic papyrus:

I set a variable to a URL string with:

set x to "http://www.apple.com";

In the script editor x is created as an object of class string. I can then successfully create an object of class URL from it with:

x as URL

If I grab a URL from Safari with:

"tell app 'safari' to set x to URL of document 1"

it returns a Unicode text string. Converting that to an object of class URL with:

x as URL

fails with the error message "Can't make ..... into a URL". Even if I coerce that Unicode text string to a plain text string, "x as URL" will still fail with the same error.

It's not really a plain text string -- it's styled text.

Is this an issue with Safari? with AppleScript? Shouldn't I be able to grab the URL string from Safari and coerce it to class URL?

Arguably, but Apple didn't implement anything to make that happen.

Thanks in advance for any explanation, if there is one.

Coercion to the URL class requires an unstyled text string. Folks have come up with various ways to unstyle a styled text string. Here's a way which combines methods from different threads that have appeared here:

tell app "Safari" to set x to URL of document 1 as record as list
item 1 of x as URL


-boo
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Unicode text and class URL
      • From: Sander Tekelenburg <email@hidden>
References: 
 >Unicode text and class URL (From: Bill Hoffman <email@hidden>)

  • Prev by Date: Re: Fink and 'sh'
  • Next by Date: Re: To .jpg or not
  • Previous by thread: Unicode text and class URL
  • Next by thread: Re: Unicode text and class URL
  • Index(es):
    • Date
    • Thread