Reputation: 89
I have written an Applescript which reads the first line of a UTF-8 text file. That string is used to "set value" a particular text area of an IRC client (Textual).
Unfortunately, any characters not native to Mac OS Roman encoding (unicode-only characters, asian-only glyphs) are substituted for Mac OS Roman characters.
For example:
is written into the text area as:
How can I force the text back into UTF-8 encoding, or fix this issue?
my script:
set source to "/Users/admin/Documents/file.txt" --UTF-8 file
set N to paragraphs of (read POSIX file source)
set phrase to first item of N
tell application "Textual" --IRC client
activate
tell application "System Events"
delay 0.3
set value of text area 1 of scroll area 1 of window 1 of process "Textual" to phrase
--the main text entry field of this application
keystroke return
end tell
end tell
Upvotes: 0
Views: 709
Reputation: 11238
Try:
set N to paragraphs of (read POSIX file source as «class utf8»)
Upvotes: 2