Re: [問題] Applescript utf8 之問題

作者: uranusjr (←這人是超級笨蛋)   2014-02-11 20:28:56
※ 引述《KORAS (NOTHING)》之銘言:
: 正開始學applescript
: run了個簡單的:
: say characters 3 through 5 of "abcdef"
: 卻跑出結果:
: error "無法將“{\"c\", \"d\", \"e\"}”製作成類型“class utf8”。
: " number -1700 from {"c", "d", "e"} to class utf8
: 請問這要怎麼克服?
: 可能因為關鍵字不對,在孤狗研究老半天沒結果,也曾在mac版問過!XD
: 感謝解惑
characters 3 thru 5 回傳的是一個 list, {"c", "d", "e"}
(應該是叫 list 吧, 很久沒碰 AppleScript 了)
但是 say 接受的受詞必須是文字
但是這兩個東西沒有辦法自動轉換, 所以就炸了
改成這樣應該就可以了
say characters 3 through 5 of "abcdef" as text
最後的 as text 會把 {"c", "d", "e"} 轉成 "cde"
讓 say 可以正常執行
作者: KORAS (NOTHING)   2014-02-12 19:53:00
感謝感謝~一語道破關鍵,原本一直以為是編碼的問題!

Links booklink

Contact Us: admin [ a t ] ucptt.com