Skip to content

Instantly share code, notes, and snippets.

@uchcode
Created July 11, 2017 02:34
Show Gist options
  • Select an option

  • Save uchcode/b8fef9ddfbcfcd26503e4edabd6018bf to your computer and use it in GitHub Desktop.

Select an option

Save uchcode/b8fef9ddfbcfcd26503e4edabd6018bf to your computer and use it in GitHub Desktop.
UTF-8 テキストファイルを読み込む ref: http://qiita.com/tom-u/items/a076a77b0cc023a29f65
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment