Я не могу ответить на ваш вопрос. В вашем коде много проблем с кодировкой applecript, но ни одна из них не вызывает ваших проблем. Applescript прекрасно обрабатывает текст, не относящийся к ascii. Я пишу на датском несколько раз, и это работает. Однако когда я попробовал свой сценарий на русском языке, я получил те же результаты, что и вы. Я не могу объяснить почему. Чтобы вы могли увидеть правильный синтаксис для чтения и записи файла, вот мой код. Обратите внимание, что я не использую Finder для выполнения этих задач, а также обратите внимание, как я устанавливаю путь для выходного файла ...
set outpath to (path to desktop as text) & "danish.txt"
set theText to "primær"
-- write the file
set openFile to open for access file outpath with write permission
write theText to openFile
close access openFile
-- read the file
set readText to read file outpath
ОБНОВЛЕНИЕ: я нашел ответ на вашу проблему. Кажется, что если вы записываете в файл метку порядка байтов utf-16, то она работает правильно для русского языка. Поэтому я создал два обработчика, чтобы вы могли читать и записывать эти файлы ...
set filePath to (path to desktop as text) & "russian.txt"
set theText to "Привет"
write_UnicodeWithBOM(filePath, theText, true)
read_UnicodeWithBOM(filePath)
on write_UnicodeWithBOM(filePath, theText)
try
set openFile to open for access file (filePath as text) with write permission
write (ASCII character 254) & (ASCII character 255) to openFile starting at 0
write theText to openFile starting at eof as Unicode text
end try
try
close access openFile
end try
end write_UnicodeWithBOM
on read_UnicodeWithBOM(filePath)
read file (filePath as text) as Unicode text
end read_UnicodeWithBOM