[JavaScript]Unicodeエスケープデコード
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # com.cocolog-nifty.quicktimer.icefloe |
004 | # |
005 | # |
006 | # |
007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
008 | use AppleScript version "2.8" |
009 | use framework "Foundation" |
010 | use scripting additions |
011 | |
012 | |
013 | ################################### |
014 | #デコード |
015 | set strSetCode to "\\u0041\\ud83d\\ude00" as Unicode text |
016 | # |
017 | set strCommandText to ("function doGetEncode() {let strText ='" & strSetCode & "';return strText;} doGetEncode();") as text |
018 | log "\n" & strCommandText & "\n" |
019 | set strExecCommand to ("/usr/bin/osascript -l JavaScript -e \"" & strCommandText & "\"") as text |
020 | try |
021 | #コマンド実行 |
022 | set strResponse to (do shell script strExecCommand) as text |
023 | log strResponse |
024 | on error |
025 | log "osascript でエラーしました" |
026 | return false |
027 | end try |
028 | |
029 | |
030 | ################################### |
031 | #文字数 |
032 | set strSetCode to "\\u0041\\ud83d\\ude00" as Unicode text |
033 | # |
034 | set strCommandText to ("function doGetEncode() {let strText ='" & strSetCode & "';let numCntChar = Array.from(strText).length;return numCntChar;} doGetEncode();") as text |
035 | log "\n" & strCommandText & "\n" |
036 | set strExecCommand to ("/usr/bin/osascript -l JavaScript -e \"" & strCommandText & "\"") as text |
037 | try |
038 | #コマンド実行 |
039 | set strResponse to (do shell script strExecCommand) as text |
040 | log strResponse |
041 | on error |
042 | log "osascript でエラーしました" |
043 | return false |
044 | end try |
AppleScriptで生成しました |
AppleScript サンプルコード
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # com.cocolog-nifty.quicktimer.icefloe |
004 | # |
005 | # |
006 | # |
007 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
008 | use AppleScript version "2.8" |
009 | use framework "Foundation" |
010 | use scripting additions |
011 | |
012 | property refMe : a reference to current application |
013 | |
014 | |
015 | set strSetValue to "\\ud83d\\ude00" as Unicode text |
016 | # |
017 | set strCommandText to ("function doGetEncode() {let strText = '" & strSetValue & "';let strCodePoint = strText.codePointAt(0);let strHexCode = strCodePoint.toString(16).toUpperCase(); return strHexCode;} doGetEncode();") as text |
018 | log "\n" & strCommandText & "\n" |
019 | set strExecCommand to ("/usr/bin/osascript -l JavaScript -e \"" & strCommandText & "\"") as text |
020 | try |
021 | #コマンド実行 |
022 | set strResponse to (do shell script strExecCommand) as text |
023 | on error |
024 | log "osascript でエラーしました" |
025 | return false |
026 | end try |
027 | set strInputText to ("U+" & strResponse) |
028 | |
029 | return strInputText |
AppleScriptで生成しました |
| 固定リンク