Skip navigation
This discussion is archived

TextEdit Unicode

2072 Views 2 Replies Latest reply: Sep 8, 2009 7:23 PM by Pierre L. RSS
Bernhard Brus Calculating status...
Currently Being Moderated
Sep 8, 2009 8:18 AM
Hi
I need a script to save a .txt file to a unicode-8 file please.
I just want to open a txt. file save as unicode 8 txt file and close the file.

with save as it does not work
iMac, Mac OS X (10.6)
  • hhas Calculating status...
    Currently Being Moderated
    Sep 8, 2009 10:25 AM (in response to Bernhard Brus)
    You could use the command line 'textutil' tool.
  • Pierre L. Level 4 Level 4 (3,860 points)
    Currently Being Moderated
    Sep 8, 2009 7:23 PM (in response to Bernhard Brus)
    Maybe you might want to try the following script. It should have TextEdit open the choosen text file and save it on the Desktop as a UTF-8 text file (under a new name).

    set theFile to choose file -- of type {"public.plain-text"} ?
    tell application "TextEdit"
    activate
    open theFile
    delay 0.5
    tell application "System Events" to tell process "TextEdit"
    keystroke "s" using {shift down, command down} -- save as
    keystroke "d" using {shift down, command down} -- on the Desktop
    tell sheet 1 of window 1
    set value of text field 1 to value of text field 1 & " (UTF-8)"
    click pop up button 1 of group 1
    click menu item "Unicode (UTF-8)" of menu 1 of pop up button 1 of group 1
    keystroke return
    delay 0.5
    if sheet 1 exists then -- (sheet 1 of sheet 1 of window 1)
    tell sheet 1 to click button "Cancel" -- don't replace a file of the same name
    keystroke "." using command down -- Cancel
    end if
    end tell
    end tell
    end tell

    Message was edited by: Pierre L.
    15-inch MacBook Pro 2.53 GHz, Mac OS X (10.5.8), AirPort Extreme

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.