1

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

breeders

变成

breed‰ rs

我尝试在我的文本返回中添加“作为 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
4

1 回答 1

5

您是否尝试过ruby -KU -e '"breeders".chars{|c|puts c.unpack("U*")[0].to_s(16)}'或搜索无法在 Character Viewer 中正确显示的字符?

read除非您添加as «class utf8»

do shell script "echo ä > /tmp/test.txt"
read POSIX file "/tmp/test.txt" as «class utf8»

as text, as string, 并且自 10.5 以来as Unicode text一直是等效的。

于 2012-07-31T09:52:55.203 回答