英文:
Why am I only able to read the first couple bytes of this file?
问题
Internetizens, this little program returns the first two characters out of the file I specified.
This is surprising to me, as the source file contains a few hundred lines of text.
What am I doing wrong? Can someone wiser spot my error please? Thank you!
-- This script will import to-dos and notes into Things from a plaintext file.
-- To run the script, click the green "Run" button in the toolbar above.
-- source: https://culturedcode.com/things/support/articles/2803555/#import-from-a-plain-text-file
set unixPath to "/Volumes/2_TB_SSD_external/Projects_2TB/computers-and-geekery/projects and languages/Obsidian development/wealthyvault/bin/logs/things-commit.db"
-- set text_file to (open for access (POSIX file unixPath))
set text item delimiters to tab
set database_text to (read POSIX file unixPath as «class utf8»)
set numparagraphs to (count paragraphs of database_text)
return database_text
英文:
Internetizens, this little program returns the first two characters out of the file I specified.
This is surprising to me, as the source file contains a few hundred lines of text.
What am I doing wrong? Can someone wiser spot my error please? Thank you!
-- This script will import to-dos and notes into Things from a plaintext file.
-- To run the script, click the green "Run" button in the toolbar above.
-- source: https://culturedcode.com/things/support/articles/2803555/#import-from-a-plain-text-file
set unixPath to "/Volumes/2_TB_SSD_external/Projects_2TB/computers-and-geekery/projects and languages/Obsidian development/wealthyvault/bin/logs/things-commit.db"
-- set text_file to (open for access (POSIX file unixPath))
set text item delimiters to tab
set database_text to (read POSIX file unixPath as «class utf8»)
set numparagraphs to (count paragraphs of database_text)
return database_text
答案1
得分: 0
我能够通过将<<utf8>>
更改为string
来解决我的问题:
set database_text to (read POSIX file unixPath as string)
不知道为什么,但这解决了问题。
英文:
I was able to solve my problem by changing <<utf8>>
to string
:
set database_text to (read POSIX file unixPath as «class utf8»)
became
set database_text to (read POSIX file unixPath as string)
I have no idea why, but this fixed the issue.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论