LoginSignup
0
0

More than 5 years have passed since last update.

UTF-8 テキストファイルを読み込む

Posted at
read_utf8_example.js
function app_read(handle, scpt='') {
    let a = Application.currentApplication()
    a.includeStandardAdditions = true
    return a.runScript(`on run argv
        read (item 1 of argv) ${scpt}
    end`, {in:'AppleScript', withParameters:handle})
}

app = Application.currentApplication()
app.includeStandardAdditions = true

p = '/Users/uchcode/Desktop/example.txt'
h = app.openForAccess(p)
r = app_read(h,'as «class utf8»')
app.closeAccess(p)

console.log(r)

macOS Sierra にて動作確認。以前は runScript のオプション withParameters を渡して実行すると原因不明のエラーが発生していた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0