0

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

不幸的是,Mac OS 罗马编码以外的任何字符(仅限 unicode 字符、仅限亚洲字形)都将替换 Mac OS 罗马字符。

例如:

  • 旦欢迎

写入文本区域为:

  • Êó¶ 欢迎

如何将文本强制转换回 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
4

1 回答 1

1

尝试:

set N to paragraphs of (read POSIX file source as «class utf8»)
于 2014-02-08T15:44:20.253 回答