Question

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:

  • 旦 welcome

is written into the text area as:

  • Êó¶ welcome

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
Was it helpful?

Solution

Try:

set N to paragraphs of (read POSIX file source as «class utf8»)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top