Applescript的System Events强制Mac OS Roman编码?

时间:2014-02-08 14:17:20

标签: unicode utf-8 character-encoding applescript mac-roman

我写了一个Applescript,它读取了UTF-8文本文件的第一行。该字符串用于“设置值”IRC客户端的特定文本区域(Textual)。

不幸的是,任何非Mac OS罗马编码原生的字符(仅限Unicode的字符,仅限亚洲字形)都将替代Mac OS罗马字符。

例如:

  • 旦欢迎

被写入文本区域:

  • Êó¶welcome

如何强制文本重新使用UTF-8编码,或解决此问题?

我的剧本:

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

1 个答案:

答案 0 :(得分:1)

尝试:

set N to paragraphs of (read POSIX file source as «class utf8»)