AppleScript 返回带有奇怪字符的文本

Zad*_*ade 1 applescript text character

我有一个脚本来返回文本文件的一部分,但我注意到它有时会返回直接查看文本文件时不可见的字符。例如,这个词:

breeders
Run Code Online (Sandbox Code Playgroud)

变成

breed‰ rs
Run Code Online (Sandbox Code Playgroud)

我尝试将“作为 Unicode 文本”添加到我的文本返回中,但这不起作用。想法?这是我的脚本:

set some_file to "[...]Words.txt" as alias
set the_text to read some_file as string
set the text item delimiters of AppleScript to ", "
set the_lines to (every text item of the_text)
return some item of the_lines as Unicode text
Run Code Online (Sandbox Code Playgroud)

Lri*_*Lri 5

您是否尝试过类似ruby -KU -e '"breeders".chars{|c|puts c.unpack("U*")[0].to_s(16)}'或搜索字符查看器中未正确显示的字符?

read除非您添加,否则会混淆非 ASCII 字符as «class utf8»:

do shell script "echo ä > /tmp/test.txt"
read POSIX file "/tmp/test.txt" as «class utf8»
Run Code Online (Sandbox Code Playgroud)

as text, as string, 和自 10.5as Unicode text起等效。