• 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: List of numbers for encoding in Microsoft Word?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: List of numbers for encoding in Microsoft Word?


  • Subject: Re: List of numbers for encoding in Microsoft Word?
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 06 Aug 2015 10:09:44 +1000

On 6 Aug 2015, at 1:51 am, William Adams <email@hidden> wrote:

Or Unicode, UTF 8

If you're running Mavericks or later, you can skip Word altogether. This is for Yosemite:

use scripting additions
use framework "Foundation"
use framework "AppKit"

on open fileList
repeat with aFile in fileList
set thePath to POSIX path of aFile
-- make NSURL
set anNSURL to (current application's class "NSURL"'s fileURLWithPath:thePath)
-- read document as rich text
set {theAttributedText, theError} to (current application's NSAttributedString's alloc()'s initWithURL:anNSURL documentAttributes:(reference))
if theAttributedText = missing value then
display dialog "Error reading '" & (anNSURL's lastPathComponent() as text) & ": " & (theError's localizedDescription() as text) buttons {"OK"}
else
-- get just text
set theString to theAttributedText's |string|()
-- make encoded data
set theData to (theString's dataUsingEncoding:(current application's NSUTF8StringEncoding))
-- save data to new file
set newURL to (anNSURL's URLByDeletingPathExtension()'s URLByAppendingPathExtension:"txt")
(theData's writeToURL:newURL atomically:true)
end if
end repeat
end open

Under Mavericks you'd need to save it as a handler in a script library, and call it from there.

Using UTF8 is likely to be more reliable than Latin 1 or WindowsCP1252.


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >List of numbers for encoding in Microsoft Word? (From: William Adams <email@hidden>)
 >Re: List of numbers for encoding in Microsoft Word? (From: Shane Stanley <email@hidden>)
 >Re: List of numbers for encoding in Microsoft Word? (From: William Adams <email@hidden>)
 >Re: List of numbers for encoding in Microsoft Word? (From: William Adams <email@hidden>)

  • Prev by Date: Re: Passing app property names
  • Next by Date: Re: Passing app property names
  • Previous by thread: Re: List of numbers for encoding in Microsoft Word?
  • Next by thread: Re: List of numbers for encoding in Microsoft Word?
  • Index(es):
    • Date
    • Thread