Encode UTF8

UTF8エンコード

Utf001
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex().upper()}\")'") as «class utf8»
114log strCommandText
115set strResponseTextAll to (do shell script strCommandText) as «class utf8»
116log strResponseTextAll
117set strOutPutText to (strOutPutText & strResponseTextAll & "\n\n") as text
118
119##文字単位 一文字づつ
120set numCntChar to (count of character of strText) as integer
121
122repeat with itemCharNo from 1 to (numCntChar) by 1
123  set strSetStr to (character itemCharNo of strText) as «class utf8»
124  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(f\"{dectext.encode().hex().upper()}\")'") as «class utf8»
125  log strCommandText
126  set strResponseText to (do shell script strCommandText) as «class utf8»
127  log strResponseText
128  set strOutPutText to (strOutPutText & strSetStr & " = " & strResponseText & "\n") as text
129  
130end repeat
131log strOutPutText
132set strOutPutText to (strOutPutText & "\n\n") as text
133
134#デコード
135set strCommandText to ("/usr/bin/python3 -c 'hex_text =\"" & strResponseTextAll & "\"; print(bytes.fromhex(hex_text).decode(\"utf-8\"))'") as «class utf8»
136log strCommandText
137set strResponseText to (do shell script strCommandText) as «class utf8»
138log strResponseText
139set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
140
141
142##############################
143#####ダイアログ
144##############################
145tell current application
146  set strName to name as text
147end tell
148####スクリプトメニューから実行したら
149if strName is "osascript" then
150  tell application "Finder"
151    activate
152  end tell
153else
154  tell current application
155    activate
156  end tell
157end if
158try
159  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
160on error
161  return "エラーしました"
162end try
163if (gave up of recordResult) is true then
164  return "時間切れです"
165end if
166##############################
167#####自分自身を再実行
168##############################
169if button returned of recordResult is "再実行" then
170  tell application "Finder"
171    set aliasPathToMe to (path to me) as alias
172  end tell
173  run script aliasPathToMe with parameters "再実行"
174end if
175##############################
176#####値のコピー
177##############################
178if button returned of recordResult is "クリップボードにコピー" then
179  try
180    set strText to text returned of recordResult as text
181    ####ペーストボード宣言
182    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
183    set ocidText to (refMe's NSString's stringWithString:(strText))
184    appPasteboard's clearContents()
185    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
186  on error
187    tell application "Finder"
188      set the clipboard to strText as text
189    end tell
190  end try
191end if
192
193
194return 0
AppleScriptで生成しました

|

[swift]UTF8エンコード



ダウンロード - utf8swift.zip




AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use scripting additions
010property refMe : a reference to current application
011
012
013set strText to ("🇯🇵'A\\") as text
014
015#######
016#メタ文字エスケープ
017set ocidText to refMe's NSString's stringWithString:(strText)
018set ocidText to (ocidText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
019set ocidText to (ocidText's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
020#エスケープ文字は入力値にあわせて増やす
021set strText to ocidText as text
022
023#######
024#パス
025set aliasPathToMe to (path to me) as alias
026set strPathToMe to (POSIX path of aliasPathToMe) as text
027set ocidPathToMeStr to refMe's NSString's stringWithString:(strPathToMe)
028set ocidPathToMe to ocidPathToMeStr's stringByStandardizingPath()
029set ocidContainerDirPath to ocidPathToMe's stringByDeletingLastPathComponent()
030set ocidBinFilePath to ocidContainerDirPath's stringByAppendingPathComponent:("script/UTF8encCap.swift")
031set strBinFilePath to ocidBinFilePath as text
032
033##【1】コマンド 大文字
034
035set strCommandText to ("\"" & strBinFilePath & "\" \"" & strText & "\"") as text
036log "\n" & strCommandText & "\n"
037#コマンド実行
038set strExecCommand to ("" & strCommandText & "") as text
039try
040  set strResponse to (do shell script strExecCommand) as text
041on error
042  return "osascript でエラーしました"
043  return false
044end try
045
046
047
048##【2】コマンド 小文字
049
050set ocidBinFilePath to ocidContainerDirPath's stringByAppendingPathComponent:("script/UTF8encLow.swift")
051set strBinFilePath to ocidBinFilePath as text
052
053set strCommandText to ("\"" & strBinFilePath & "\" \"" & strText & "\"") as text
054log "\n" & strCommandText & "\n"
055#コマンド実行
056set strExecCommand to ("" & strCommandText & "") as text
057try
058  set strResponse to (do shell script strExecCommand) as text
059on error
060  log "osascript でエラーしました"
061  return false
062end try
AppleScriptで生成しました

サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env swift
002//  
003import Foundation
004
005let argString: [String] = CommandLine.arguments
006let strInput: String = argString[1]
007let utf8Bytes: [String.UTF8View.Element] = Array(strInput.utf8)
008
009for byte: String.UTF8View.Element in utf8Bytes {
010    print(String(format: "%02X", byte), terminator: " ")
011}
012print()
AppleScriptで生成しました

|

[xxd]UTF8エンコード


サンプルコード

サンプルソース(参考)
行番号ソース
001#!/usr/bin/env zsh
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use scripting additions
010property refMe : a reference to current application
011
012
013set strText to ("🇯🇵A") as text
014
015
016##【1】コマンド 小文字
017
018set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p") as text
019log "\n" & strCommandText & "\n"
020#コマンド実行
021set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
022try
023  set strResponse to (do shell script strExecCommand) as text
024on error
025  log "zsh でエラーしました"
026  return false
027end try
028
029
030##【2】コマンド 大文字
031
032set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p | /usr/bin/tr '[:lower:]' '[:upper:]'") as text
033log "\n" & strCommandText & "\n"
034#コマンド実行
035set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
036try
037  set strResponse to (do shell script strExecCommand) as text
038on error
039  log "zsh でエラーしました"
040  return false
041end try
042
043
044##【3】コマンド 小文字 スペース区切り
045
046set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p | /usr/bin/sed 's/../& /g'") as text
047log "\n" & strCommandText & "\n"
048#コマンド実行
049set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
050try
051  set strResponse to (do shell script strExecCommand) as text
052on error
053  log "zsh でエラーしました"
054  return false
055end try
056
057
058##【4】コマンド 大文字 スペース区切り
059
060set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p | /usr/bin/tr '[:lower:]' '[:upper:]' | /usr/bin/sed 's/../& /g'") as text
061log "\n" & strCommandText & "\n"
062#コマンド実行
063set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
064try
065  set strResponse to (do shell script strExecCommand) as text
066on error
067  log "zsh でエラーしました"
068  return false
069end try
070
071
072##【5】コマンド 小文字 %エンコード
073
074set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p | /usr/bin/sed 's/../%&/g'") as text
075log "\n" & strCommandText & "\n"
076#コマンド実行
077set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
078try
079  set strResponse to (do shell script strExecCommand) as text
080on error
081  log "zsh でエラーしました"
082  return false
083end try
084
085
086##【4】コマンド 大文字 %エンコード
087
088set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -p | /usr/bin/tr '[:lower:]' '[:upper:]' | /usr/bin/sed 's/../%&/g'") as text
089log "\n" & strCommandText & "\n"
090#コマンド実行
091set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
092try
093  set strResponse to (do shell script strExecCommand) as text
094on error
095  log "zsh でエラーしました"
096  return false
097end try
098
099
100##【5】コマンド 小文字 見た目の文字毎スペース区切り
101set numCntText to (count of (every text item of strText)) as integer
102set strOutPutText to "" as text
103repeat with itemNo from 1 to numCntText by 1
104  set strChar to text item itemNo of strText as text
105  #コマンド整形
106  set strCommandText to ("/usr/bin/printf \"" & strChar & "\" | /usr/bin/xxd -p") as text
107  log "\n" & strCommandText & "\n"
108  #コマンド実行
109  set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
110  try
111    set strResponse to (do shell script strExecCommand) as text
112  on error
113    log "zsh でエラーしました"
114    return false
115  end try
116  if itemNo = 1 then
117    set strOutPutText to (strOutPutText & strResponse) as text
118  else
119    set strOutPutText to (strOutPutText & " " & strResponse) as text
120  end if
121end repeat
122
123log strOutPutText
124
125
126##【6】コマンド 大文字 見た目の文字毎スペース区切り
127set numCntText to (count of (every text item of strText)) as integer
128set strOutPutText to "" as text
129repeat with itemNo from 1 to numCntText by 1
130  set strChar to text item itemNo of strText as text
131  #コマンド整形
132  set strCommandText to ("/usr/bin/printf \"" & strChar & "\" | /usr/bin/xxd -p |  /usr/bin/tr '[:lower:]' '[:upper:]' ") as text
133  log "\n" & strCommandText & "\n"
134  #コマンド実行
135  set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
136  try
137    set strResponse to (do shell script strExecCommand) as text
138  on error
139    log "zsh でエラーしました"
140    return false
141  end try
142  if itemNo = 1 then
143    set strOutPutText to (strOutPutText & strResponse) as text
144  else
145    set strOutPutText to (strOutPutText & " " & strResponse) as text
146  end if
147end repeat
148
149log strOutPutText
AppleScriptで生成しました

|

[python3]UTF8エンコード


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use scripting additions
010property refMe : a reference to current application
011
012
013set strText to ("🇯🇵") as text
014
015
016
017##【1】python3コマンド 大文字
018
019set strCommandText to ("dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex().upper()}\")") as «class utf8»
020log "\n" & strCommandText & "\n"
021#コマンド実行
022set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
023try
024  set strResponse to (do shell script strExecCommand) as text
025on error
026  log "python3 でエラーしました"
027  return false
028end try
029
030
031
032##【2】python3コマンド 大文字 文字毎 スペース区切り
033
034set strCommandText to ("dectext=\"" & strText & "\"; print(\" \".join(f\"{char.encode().hex().upper()}\" for char in dectext))") as «class utf8»
035log "\n" & strCommandText & "\n"
036#コマンド実行
037set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
038try
039  set strResponse to (do shell script strExecCommand) as text
040on error
041  log "python3 でエラーしました"
042  return false
043end try
044
045
046
047
048##【3】python3コマンド 大文字 スペース区切り
049
050set strCommandText to ("dectext=\"" & strText & "\"; print(\" \".join(f\"{byte:02X}\" for byte in dectext.encode()))") as «class utf8»
051log "\n" & strCommandText & "\n"
052#コマンド実行
053set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
054try
055  set strResponse to (do shell script strExecCommand) as text
056on error
057  log "python3 でエラーしました"
058  return false
059end try
060
061##【3】python3コマンド 大文字 %エンコード
062
063set strCommandText to ("dectext=\"" & strText & "\"; print(\"&\" + \"&\".join(f\"{byte:02X}\" for byte in dectext.encode()))") as «class utf8»
064log "\n" & strCommandText & "\n"
065#コマンド実行
066set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
067try
068  set strResponse to (do shell script strExecCommand) as text
069on error
070  log "python3 でエラーしました"
071  return false
072end try
073
074
075
076
077
078##【5】python3コマンド 小文字
079
080set strCommandText to ("dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex().lower()}\")") as «class utf8»
081log "\n" & strCommandText & "\n"
082#コマンド実行
083set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
084try
085  set strResponse to (do shell script strExecCommand) as text
086on error
087  log "python3 でエラーしました"
088  return false
089end try
090
091
092
093##【6】python3コマンド 小文字 文字毎 スペース区切り
094
095set strCommandText to ("dectext=\"" & strText & "\"; print(\" \".join(f\"{char.encode().hex().lower()}\" for char in dectext))") as «class utf8»
096log "\n" & strCommandText & "\n"
097#コマンド実行
098set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
099try
100  set strResponse to (do shell script strExecCommand) as text
101on error
102  log "python3 でエラーしました"
103  return false
104end try
105
106##【7】python3コマンド 小文字 スペース区切り
107
108set strCommandText to ("dectext=\"" & strText & "\"; print(\" \".join(f\"{byte:02x}\" for byte in dectext.encode()))") as «class utf8»
109log "\n" & strCommandText & "\n"
110#コマンド実行
111set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
112try
113  set strResponse to (do shell script strExecCommand) as text
114on error
115  log "python3 でエラーしました"
116  return false
117end try
118
119##【7】python3コマンド 小文字 %エンコード
120
121set strCommandText to ("dectext=\"" & strText & "\"; print(\"&\" + \"&\".join(f\"{byte:02x}\" for byte in dectext.encode()))") as «class utf8»
122log "\n" & strCommandText & "\n"
123#コマンド実行
124set strExecCommand to ("/usr/bin/python3 -c '" & strCommandText & "'") as text
125try
126  set strResponse to (do shell script strExecCommand) as text
127on error
128  log "python3 でエラーしました"
129  return false
130end try
AppleScriptで生成しました

|

[zsh]UTF8デコード


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# Data フォルダにUnicodeData.plistが必要です
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "UniformTypeIdentifiers"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013
014
015set strText to ("f09f87aff09f87b541") as text
016
017
018##【1】コマンド 小文字
019
020set strCommandText to ("/usr/bin/printf \"" & strText & "\" | /usr/bin/xxd -r -p") as text
021log "\n" & strCommandText & "\n"
022#コマンド実行
023set strExecCommand to ("/bin/zsh -c \"" & strCommandText & "\"") as text
024try
025  set strResponse to (do shell script strExecCommand) as text
026on error
027  log "zsh でエラーしました"
028  return false
029end try
030
031
032log strResponse
AppleScriptで生成しました

|

[AppleScript]UTF8エンコード


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# UNIXコマンド char stringWithFormatが使えない前提の場合
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use scripting additions
010property refMe : a reference to current application
011
012set strText to ("AN日$£🇯🇵") as text
013
014set numCntText to (count of (every text item of strText)) as integer
015set strOutputText to "" as text
016##キャラクタセットを指定
017set ocidChrSet to (refMe's NSCharacterSet's URLQueryAllowedCharacterSet)
018
019repeat with itemTextNo from 1 to numCntText by 1
020  set strItemText to (text item itemTextNo of strText) as text
021  set ocidTextString to (refMe's NSString's stringWithString:(strItemText))
022  ##キャラクタセットで変換
023  set ocidTextToEncoded to (ocidTextString's stringByAddingPercentEncodingWithAllowedCharacters:(ocidChrSet))
024  set strTextToEncoded to ocidTextToEncoded as text
025  if strTextToEncoded is strItemText then
026    #エンコード前と後が同じ=アスキー等QueryAllowed以外の文字
027    #文字の10進数コードを取得して
028    set numUniDec to (ocidTextString's characterAtIndex:(0)) as integer
029    set ocidDec2HexDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
030    #HEXの値を取得する
031    (ocidDec2HexDict's setDictionary:(recordDec2HexUpp))
032    set strValue to (ocidDec2HexDict's valueForKey:(numUniDec as text))
033    set strItemStr to strValue as text
034  else
035    #エンコードされた文字列は%をスペースに置換してUTF8コード
036    set ocidEncodArray to (ocidTextToEncoded's componentsSeparatedByString:("%"))
037    set numCntArray to ocidEncodArray's |count|()
038    repeat with itemArrayNo from 0 to (numCntArray - 1) by 1
039      set strItemArrayEnc to (ocidEncodArray's objectAtIndex:(itemArrayNo))
040      if itemArrayNo = 0 then
041        set strArrayString to "" as text
042      else if itemArrayNo = 1 then
043        set strArrayString to strArrayString & strItemArrayEnc as text
044      else
045        set strArrayString to (strArrayString & " " & (strItemArrayEnc as text)) as text
046      end if
047    end repeat
048    set strItemStr to strArrayString as text
049  end if
050  if itemTextNo = 1 then
051    set strOutputText to strOutputText & strItemStr as text
052  else
053    set strOutputText to strOutputText & " " & strItemStr as text
054  end if
055end repeat
056
057log strOutputText
058return
059
060property recordDec2HexUpp : {|0|:"00", |1|:"01", |2|:"02", |3|:"03", |4|:"04", |5|:"05", |6|:"06", |7|:"07", |8|:"08", |9|:"09", |10|:"0A", |11|:"0B", |12|:"0C", |13|:"0D", |14|:"0E", |15|:"0F", |16|:"10", |17|:"11", |18|:"12", |19|:"13", |20|:"14", |21|:"15", |22|:"16", |23|:"17", |24|:"18", |25|:"19", |26|:"1A", |27|:"1B", |28|:"1C", |29|:"1D", |30|:"1E", |31|:"1F", |32|:"20", |33|:"21", |34|:"22", |35|:"23", |36|:"24", |37|:"25", |38|:"26", |39|:"27", |40|:"28", |41|:"29", |42|:"2A", |43|:"2B", |44|:"2C", |45|:"2D", |46|:"2E", |47|:"2F", |48|:"30", |49|:"31", |50|:"32", |51|:"33", |52|:"34", |53|:"35", |54|:"36", |55|:"37", |56|:"38", |57|:"39", |58|:"3A", |59|:"3B", |60|:"3C", |61|:"3D", |62|:"3E", |63|:"3F", |64|:"40", |65|:"41", |66|:"42", |67|:"43", |68|:"44", |69|:"45", |70|:"46", |71|:"47", |72|:"48", |73|:"49", |74|:"4A", |75|:"4B", |76|:"4C", |77|:"4D", |78|:"4E", |79|:"4F", |80|:"50", |81|:"51", |82|:"52", |83|:"53", |84|:"54", |85|:"55", |86|:"56", |87|:"57", |88|:"58", |89|:"59", |90|:"5A", |91|:"5B", |92|:"5C", |93|:"5D", |94|:"5E", |95|:"5F", |96|:"60", |97|:"61", |98|:"62", |99|:"63", |100|:"64", |101|:"65", |102|:"66", |103|:"67", |104|:"68", |105|:"69", |106|:"6A", |107|:"6B", |108|:"6C", |109|:"6D", |110|:"6E", |111|:"6F", |112|:"70", |113|:"71", |114|:"72", |115|:"73", |116|:"74", |117|:"75", |118|:"76", |119|:"77", |120|:"78", |121|:"79", |122|:"7A", |123|:"7B", |124|:"7C", |125|:"7D", |126|:"7E", |127|:"7F", |128|:"80", |129|:"81", |130|:"82", |131|:"83", |132|:"84", |133|:"85", |134|:"86", |135|:"87", |136|:"88", |137|:"89", |138|:"8A", |139|:"8B", |140|:"8C", |141|:"8D", |142|:"8E", |143|:"8F", |144|:"90", |145|:"91", |146|:"92", |147|:"93", |148|:"94", |149|:"95", |150|:"96", |151|:"97", |152|:"98", |153|:"99", |154|:"9A", |155|:"9B", |156|:"9C", |157|:"9D", |158|:"9E", |159|:"9F", |160|:"A0", |161|:"A1", |162|:"A2", |163|:"A3", |164|:"A4", |165|:"A5", |166|:"A6", |167|:"A7", |168|:"A8", |169|:"A9", |170|:"AA", |171|:"AB", |172|:"AC", |173|:"AD", |174|:"AE", |175|:"AF", |176|:"B0", |177|:"B1", |178|:"B2", |179|:"B3", |180|:"B4", |181|:"B5", |182|:"B6", |183|:"B7", |184|:"B8", |185|:"B9", |186|:"BA", |187|:"BB", |188|:"BC", |189|:"BD", |190|:"BE", |191|:"BF", |192|:"C0", |193|:"C1", |194|:"C2", |195|:"C3", |196|:"C4", |197|:"C5", |198|:"C6", |199|:"C7", |200|:"C8", |201|:"C9", |202|:"CA", |203|:"CB", |204|:"CC", |205|:"CD", |206|:"CE", |207|:"CF", |208|:"D0", |209|:"D1", |210|:"D2", |211|:"D3", |212|:"D4", |213|:"D5", |214|:"D6", |215|:"D7", |216|:"D8", |217|:"D9", |218|:"DA", |219|:"DB", |220|:"DC", |221|:"DD", |222|:"DE", |223|:"DF", |224|:"E0", |225|:"E1", |226|:"E2", |227|:"E3", |228|:"E4", |229|:"E5", |230|:"E6", |231|:"E7", |232|:"E8", |233|:"E9", |234|:"EA", |235|:"EB", |236|:"EC", |237|:"ED", |238|:"EE", |239|:"EF", |240|:"F0", |241|:"F1", |242|:"F2", |243|:"F3", |244|:"F4", |245|:"F5", |246|:"F6", |247|:"F7", |248|:"F8", |249|:"F9", |250|:"FA", |251|:"FB", |252|:"FC", |253|:"FD", |254|:"FE", |255|:"FF"} as record
AppleScriptで生成しました

|

[perl]UTF8エンコード(サロゲート対応)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004#
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use scripting additions
010property refMe : a reference to current application
011
012
013set strText to ("🇯🇵") as text
014
015
016##【1】perlコマンド 大文字
017
018set strCommandText to ("say sprintf(\"%X\", $_) for unpack(\"U*\", \"" & strText & "\")") as «class utf8»
019log "\n" & strCommandText & "\n"
020#コマンド実行
021set strExecCommand to ("/usr/bin/perl -C -E '" & strCommandText & "' | /usr/bin/tr \"\n\" \" \"") as text
022try
023  set strResponse to (do shell script strExecCommand) as text
024on error
025  log "osascript でエラーしました"
026  return false
027end try
028
029
030##【1】perlコマンド 小文字
031
032set strCommandText to ("say sprintf(\"%x\", $_) for unpack(\"U*\", \"" & strText & "\")") as «class utf8»
033log "\n" & strCommandText & "\n"
034#コマンド実行
035set strExecCommand to ("/usr/bin/perl -C -E '" & strCommandText & "' | /usr/bin/tr \"\n\" \" \"") as text
036try
037  set strResponse to (do shell script strExecCommand) as text
038on error
039  log "osascript でエラーしました"
040  return false
041end try
AppleScriptで生成しました

|

[python3]UTF8エンコード 少し改良


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex().upper()}\")'") as «class utf8»
114set strResponseTextAll to (do shell script strCommandText) as «class utf8»
115set strOutPutText to (strOutPutText & strResponseTextAll & "\n") as text
116#2バイト毎でスペース区切る
117##文字列全体
118set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(\" \".join(f\"{byte:02X}\" for byte in dectext.encode()))'") as «class utf8»
119set strResponseTextAllS to (do shell script strCommandText) as «class utf8»
120set strOutPutText to (strOutPutText & strResponseTextAllS & "\n") as text
121#文字毎でスペース区切る
122##文字列全体
123set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(\" \".join(f\"{char.encode().hex().upper()}\" for char in dectext))'") as «class utf8»
124set strResponseTextAllW to (do shell script strCommandText) as «class utf8»
125set strOutPutText to (strOutPutText & strResponseTextAllW & "\n\n") as text
126
127
128##文字単位 一文字づつ
129set numCntChar to (count of character of strText) as integer
130
131repeat with itemCharNo from 1 to (numCntChar) by 1
132  set strSetStr to (character itemCharNo of strText) as «class utf8»
133  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(\" \".join(f\"{byte:02X}\" for byte in dectext.encode()))'") as «class utf8»
134  log strCommandText
135  set strResponseText to (do shell script strCommandText) as «class utf8»
136  log strResponseText
137  set strOutPutText to (strOutPutText & strSetStr & " = " & strResponseText & "\n") as text
138  
139end repeat
140log strOutPutText
141set strOutPutText to (strOutPutText & "\n\n") as text
142
143#デコード
144set strCommandText to ("/usr/bin/python3 -c 'hex_text =\"" & strResponseTextAll & "\"; print(bytes.fromhex(hex_text).decode(\"utf-8\"))'") as «class utf8»
145log strCommandText
146set strResponseText to (do shell script strCommandText) as «class utf8»
147log strResponseText
148set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
149
150
151##############################
152#####ダイアログ
153##############################
154tell current application
155  set strName to name as text
156end tell
157####スクリプトメニューから実行したら
158if strName is "osascript" then
159  tell application "Finder"
160    activate
161  end tell
162else
163  tell current application
164    activate
165  end tell
166end if
167try
168  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
169on error
170  return "エラーしました"
171end try
172if (gave up of recordResult) is true then
173  return "時間切れです"
174end if
175##############################
176#####自分自身を再実行
177##############################
178if button returned of recordResult is "再実行" then
179  tell application "Finder"
180    set aliasPathToMe to (path to me) as alias
181  end tell
182  run script aliasPathToMe with parameters "再実行"
183end if
184##############################
185#####値のコピー
186##############################
187if button returned of recordResult is "クリップボードにコピー" then
188  try
189    set strText to text returned of recordResult as text
190    ####ペーストボード宣言
191    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
192    set ocidText to (refMe's NSString's stringWithString:(strText))
193    appPasteboard's clearContents()
194    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
195  on error
196    tell application "Finder"
197      set the clipboard to strText as text
198    end tell
199  end try
200end if
201
202
203return 0
AppleScriptで生成しました

|

[python3]文字列からUTF16のユニコード番号を取得する

小文字でエンコード
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print( dectext.encode().hex().upper())'") as Unicode text
114log strCommandText
115set strResponseTextAll to (do shell script strCommandText) as «class utf8»
116log strResponseTextAll
117set strOutPutText to (strOutPutText & strResponseTextAll & "\n\n") as text
118
119##文字単位 一文字づつ
120set numCntChar to (count of character of strText) as integer
121set strJoinString to ("") as text
122repeat with itemCharNo from 1 to (numCntChar) by 1
123  set strSetStr to (character itemCharNo of strText) as «class utf8»
124  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(\"\".join([f\"\\\\x{b:02x}\" for b in dectext.encode()]))'") as Unicode text
125  log strCommandText
126  set strResponseText to (do shell script strCommandText) as «class utf8»
127  log strResponseText
128  set strOutPutText to (strOutPutText & strSetStr & "=" & strResponseText & "\n") as text
129  set strJoinString to (strJoinString & strResponseText) as text
130end repeat
131log strOutPutText
132set strOutPutText to (strOutPutText & "\n\n") as text
133
134#デコード
135set strCommandText to ("/usr/bin/python3 -c 'escaped_text = b\"" & strJoinString & "\";print(escaped_text.decode(\"utf-8\"))'") as Unicode text
136log strCommandText
137set strResponseText to (do shell script strCommandText) as «class utf8»
138log strResponseText
139set strOutPutText to (strOutPutText & strJoinString & "\n") as text
140set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
141
142
143##############################
144#####ダイアログ
145##############################
146tell current application
147  set strName to name as text
148end tell
149####スクリプトメニューから実行したら
150if strName is "osascript" then
151  tell application "Finder"
152    activate
153  end tell
154else
155  tell current application
156    activate
157  end tell
158end if
159try
160  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
161on error
162  return "エラーしました"
163end try
164if (gave up of recordResult) is true then
165  return "時間切れです"
166end if
167##############################
168#####自分自身を再実行
169##############################
170if button returned of recordResult is "再実行" then
171  tell application "Finder"
172    set aliasPathToMe to (path to me) as alias
173  end tell
174  run script aliasPathToMe with parameters "再実行"
175end if
176##############################
177#####値のコピー
178##############################
179if button returned of recordResult is "クリップボードにコピー" then
180  try
181    set strText to text returned of recordResult as text
182    ####ペーストボード宣言
183    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
184    set ocidText to (refMe's NSString's stringWithString:(strText))
185    appPasteboard's clearContents()
186    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
187  on error
188    tell application "Finder"
189      set the clipboard to strText as text
190    end tell
191  end try
192end if
193
194
195return 0
AppleScriptで生成しました

エスケープ大文字
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print( dectext.encode().hex().upper())'") as Unicode text
114log strCommandText
115set strResponseTextAll to (do shell script strCommandText) as «class utf8»
116log strResponseTextAll
117set strOutPutText to (strOutPutText & strResponseTextAll & "\n\n") as text
118
119##文字単位 一文字づつ
120set numCntChar to (count of character of strText) as integer
121set strJoinString to ("") as text
122repeat with itemCharNo from 1 to (numCntChar) by 1
123  set strSetStr to (character itemCharNo of strText) as «class utf8»
124  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(\"\".join([f\"\\\\x{b:02X}\" for b in dectext.encode()]))'") as Unicode text
125  log strCommandText
126  set strResponseText to (do shell script strCommandText) as «class utf8»
127  log strResponseText
128  set strOutPutText to (strOutPutText & strSetStr & "=" & strResponseText & "\n") as text
129  set strJoinString to (strJoinString & strResponseText) as text
130end repeat
131log strOutPutText
132set strOutPutText to (strOutPutText & "\n\n") as text
133
134#デコード
135set strCommandText to ("/usr/bin/python3 -c 'escaped_text = b\"" & strJoinString & "\";print(escaped_text.decode(\"utf-8\"))'") as Unicode text
136log strCommandText
137set strResponseText to (do shell script strCommandText) as «class utf8»
138log strResponseText
139set strOutPutText to (strOutPutText & strJoinString & "\n") as text
140set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
141
142
143##############################
144#####ダイアログ
145##############################
146tell current application
147  set strName to name as text
148end tell
149####スクリプトメニューから実行したら
150if strName is "osascript" then
151  tell application "Finder"
152    activate
153  end tell
154else
155  tell current application
156    activate
157  end tell
158end if
159try
160  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
161on error
162  return "エラーしました"
163end try
164if (gave up of recordResult) is true then
165  return "時間切れです"
166end if
167##############################
168#####自分自身を再実行
169##############################
170if button returned of recordResult is "再実行" then
171  tell application "Finder"
172    set aliasPathToMe to (path to me) as alias
173  end tell
174  run script aliasPathToMe with parameters "再実行"
175end if
176##############################
177#####値のコピー
178##############################
179if button returned of recordResult is "クリップボードにコピー" then
180  try
181    set strText to text returned of recordResult as text
182    ####ペーストボード宣言
183    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
184    set ocidText to (refMe's NSString's stringWithString:(strText))
185    appPasteboard's clearContents()
186    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
187  on error
188    tell application "Finder"
189      set the clipboard to strText as text
190    end tell
191  end try
192end if
193
194
195return 0
AppleScriptで生成しました

|

[python3]文字列からUTF8の文字コードを取得する

戻り値小文字
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex()}\")'") as «class utf8»
114log strCommandText
115set strResponseTextAll to (do shell script strCommandText) as «class utf8»
116log strResponseTextAll
117set strOutPutText to (strOutPutText & strResponseTextAll & "\n\n") as text
118
119##文字単位 一文字づつ
120set numCntChar to (count of character of strText) as integer
121
122repeat with itemCharNo from 1 to (numCntChar) by 1
123  set strSetStr to (character itemCharNo of strText) as «class utf8»
124  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(f\"{dectext.encode().hex()}\")'") as «class utf8»
125  log strCommandText
126  set strResponseText to (do shell script strCommandText) as «class utf8»
127  log strResponseText
128  set strOutPutText to (strOutPutText & strSetStr & "=" & strResponseText & "\n") as text
129  
130end repeat
131log strOutPutText
132set strOutPutText to (strOutPutText & "\n\n") as text
133
134#デコード
135set strCommandText to ("/usr/bin/python3 -c 'hex_text =\"" & strResponseTextAll & "\"; print(bytes.fromhex(hex_text).decode(\"utf-8\"))'") as «class utf8»
136log strCommandText
137set strResponseText to (do shell script strCommandText) as «class utf8»
138log strResponseText
139set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
140
141
142##############################
143#####ダイアログ
144##############################
145tell current application
146  set strName to name as text
147end tell
148####スクリプトメニューから実行したら
149if strName is "osascript" then
150  tell application "Finder"
151    activate
152  end tell
153else
154  tell current application
155    activate
156  end tell
157end if
158try
159  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
160on error
161  return "エラーしました"
162end try
163if (gave up of recordResult) is true then
164  return "時間切れです"
165end if
166##############################
167#####自分自身を再実行
168##############################
169if button returned of recordResult is "再実行" then
170  tell application "Finder"
171    set aliasPathToMe to (path to me) as alias
172  end tell
173  run script aliasPathToMe with parameters "再実行"
174end if
175##############################
176#####値のコピー
177##############################
178if button returned of recordResult is "クリップボードにコピー" then
179  try
180    set strText to text returned of recordResult as text
181    ####ペーストボード宣言
182    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
183    set ocidText to (refMe's NSString's stringWithString:(strText))
184    appPasteboard's clearContents()
185    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
186  on error
187    tell application "Finder"
188      set the clipboard to strText as text
189    end tell
190  end try
191end if
192
193
194return 0
AppleScriptで生成しました

戻り値大文字
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# python3が必要です
004# macOS12以降の場合Xcodeかコマンドラインツールが必要です
005#
006# com.cocolog-nifty.quicktimer.icefloe
007----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
008use AppleScript version "2.8"
009use framework "Foundation"
010use framework "AppKit"
011use scripting additions
012property refMe : a reference to current application
013property refNSNotFound : a reference to 9.22337203685477E+18 + 5807
014
015
016set strText to ("文字列を入力") as «class utf8»
017
018try
019  do shell script ("/usr/bin/which python3")
020on error
021  do shell script ("/usr/bin/xcode-select --install")
022end try
023########################
024## クリップボードの中身取り出し
025########################
026###初期化
027set appPasteboard to refMe's NSPasteboard's generalPasteboard()
028##格納されているタイプをリストにして
029set ocidPastBoardTypeArray to appPasteboard's types
030###テキストがあれば
031set boolContain to ocidPastBoardTypeArray's containsObject:("public.utf8-plain-text")
032if (boolContain as boolean) is true then
033  ###値を格納する
034  tell application "Finder"
035    set strReadString to (the clipboard as text) as «class utf8»
036  end tell
037else
038  ###UTF8が無いなら
039  ##テキスト形式があるか?確認して
040  set boolContain to ocidPastBoardTypeArray's containsObject:(refMe's NSPasteboardTypeString)
041  ##テキスト形式があるなら
042  if (boolContain as boolean) is true then
043    set ocidTypeClassArray to refMe's NSMutableArray's alloc()'s initWithCapacity:(0)
044    ocidTypeClassArray's addObject:(refMe's NSString)
045    set ocidReadString to appPasteboard's readObjectsForClasses:(ocidTypeClassArray) options:(missing value)
046    set strReadString to ocidReadString as «class utf8»
047  else
048    log "テキストなし"
049    set strReadString to strMes as «class utf8»
050  end if
051end if
052##############################
053#####ダイアログ
054##############################
055###ダイアログを前面に出す
056set strName to (name of current application) as text
057if strName is "osascript" then
058  tell application "Finder" to activate
059else
060  tell current application to activate
061end if
062set strMes to "変換するテキストを入力してください"
063set aliasIconPath to POSIX file "/System/Applications/Calculator.app/Contents/Resources/AppIcon.icns" as alias
064try
065  set recordResult to (display dialog strMes with title "入力してください" default answer strReadString buttons {"OK", "キャンセル"} default button "OK" with icon aliasIconPath giving up after 20 without hidden answer) as record
066on error
067  log "エラーしました"
068  return
069end try
070if "OK" is equal to (button returned of recordResult) then
071  set strReturnedText to (text returned of recordResult) as «class utf8»
072else if (gave up of recordResult) is true then
073  return "時間切れです"
074else
075  return "キャンセル"
076end if
077##############################
078#####戻り値整形
079##############################
080set ocidResponseText to (refMe's NSString's stringWithString:(strReturnedText))
081###タブと改行を除去しておく
082set ocidTextM to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083ocidTextM's appendString:(ocidResponseText)
084###除去する文字列リスト
085set listRemoveChar to {"\n", "\r", "\t"} as list
086##置換
087repeat with itemChar in listRemoveChar
088  set strPattern to itemChar as text
089  set strTemplate to ("") as text
090  set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
091  set listResponse to (refMe's NSRegularExpression's regularExpressionWithPattern:(strPattern) options:(ocidOption) |error| :(reference))
092  if (item 2 of listResponse) ≠ (missing value) then
093    log (item 2 of listResponse)'s localizedDescription() as text
094    return "正規表現パターンに誤りがあります"
095  else
096    set ocidRegex to (item 1 of listResponse)
097  end if
098  set numLength to ocidResponseText's |length|()
099  set ocidRange to refMe's NSRange's NSMakeRange(0, numLength)
100  set ocidResponseText to (ocidRegex's stringByReplacingMatchesInString:(ocidResponseText) options:0 range:(ocidRange) withTemplate:(strTemplate))
101end repeat
102
103###最低限のエスケープ処理
104set ocidReplacedStrings to (ocidResponseText's stringByReplacingOccurrencesOfString:("\\") withString:("\\\\"))
105set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("'") withString:("\\'"))
106set ocidReplacedStrings to (ocidReplacedStrings's stringByReplacingOccurrencesOfString:("\"") withString:("\\\""))
107set strText to ocidReplacedStrings as «class utf8»
108
109###戻り値用テキスト
110set strOutPutText to (strText & "\n") as text
111
112##文字列全体
113set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strText & "\"; print(f\"{dectext.encode().hex().upper()}\")'") as «class utf8»
114log strCommandText
115set strResponseTextAll to (do shell script strCommandText) as «class utf8»
116log strResponseTextAll
117set strOutPutText to (strOutPutText & strResponseTextAll & "\n\n") as text
118
119##文字単位 一文字づつ
120set numCntChar to (count of character of strText) as integer
121
122repeat with itemCharNo from 1 to (numCntChar) by 1
123  set strSetStr to (character itemCharNo of strText) as «class utf8»
124  set strCommandText to ("/usr/bin/python3 -c 'dectext=\"" & strSetStr & "\"; print(f\"{dectext.encode().hex().upper()}\")'") as «class utf8»
125  log strCommandText
126  set strResponseText to (do shell script strCommandText) as «class utf8»
127  log strResponseText
128  set strOutPutText to (strOutPutText & strSetStr & " = " & strResponseText & "\n") as text
129  
130end repeat
131log strOutPutText
132set strOutPutText to (strOutPutText & "\n\n") as text
133
134#デコード
135set strCommandText to ("/usr/bin/python3 -c 'hex_text =\"" & strResponseTextAll & "\"; print(bytes.fromhex(hex_text).decode(\"utf-8\"))'") as «class utf8»
136log strCommandText
137set strResponseText to (do shell script strCommandText) as «class utf8»
138log strResponseText
139set strOutPutText to (strOutPutText & strResponseText & "\n\n") as text
140
141
142##############################
143#####ダイアログ
144##############################
145tell current application
146  set strName to name as text
147end tell
148####スクリプトメニューから実行したら
149if strName is "osascript" then
150  tell application "Finder"
151    activate
152  end tell
153else
154  tell current application
155    activate
156  end tell
157end if
158try
159  set recordResult to (display dialog strMes with title "戻り値です" default answer strOutPutText buttons {"クリップボードにコピー", "終了", "再実行"} default button "再実行" cancel button "終了" giving up after 20 with icon aliasIconPath without hidden answer) as record
160on error
161  return "エラーしました"
162end try
163if (gave up of recordResult) is true then
164  return "時間切れです"
165end if
166##############################
167#####自分自身を再実行
168##############################
169if button returned of recordResult is "再実行" then
170  tell application "Finder"
171    set aliasPathToMe to (path to me) as alias
172  end tell
173  run script aliasPathToMe with parameters "再実行"
174end if
175##############################
176#####値のコピー
177##############################
178if button returned of recordResult is "クリップボードにコピー" then
179  try
180    set strText to text returned of recordResult as text
181    ####ペーストボード宣言
182    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
183    set ocidText to (refMe's NSString's stringWithString:(strText))
184    appPasteboard's clearContents()
185    appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
186  on error
187    tell application "Finder"
188      set the clipboard to strText as text
189    end tell
190  end try
191end if
192
193
194return 0
AppleScriptで生成しました

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom