我有一個簡單的代碼將文本文件讀入列表中。它是這種格式的CMYK值列表:00, 100, 64, 33
。出於某種原因,輸出將替換具有奇怪字符的空間......「¬†」(返回和匕首?)。Applescript:替換空間的奇怪字符(「¬†」)
所以這個腳本:
set cmykList to {}
set eachLine to paragraphs of (read POSIX file "/Users/me/Desktop/cmyk.txt")
repeat with nextLine in eachLine
if length of nextLine is greater than 0 then
copy (nextLine as text) to the end of cmykList
end if
end repeat
choose from list cmykList
回報: 00,¬†100,¬†64,¬†33, 00,¬†00,¬†00,¬†00, 100,¬†72,¬†00, 100,¬†35,¬†00,¬†100
爲什麼這是任何想法,我怎樣才能避免這種情況?
文本文件設置像這樣:
00, 100, 64, 33
00, 00, 00, 00
100, 72, 00, 18
100, 35, 00, 100
00, 16, 100, 00
00, 100, 63, 29
00, 66, 100, 07
03, 00, 00, 32
100, 35, 00, 100
00, 100, 81, 04
04, 02, 00, 45
00, 00, 00, 00
03, 00, 00, 32
100, 35, 00, 100
編輯:解決了這個問題做一個查找/替換:
set cmykList to {}
set eachLine to paragraphs of (read POSIX file "/Users/me/Desktop/cmyk.txt")
repeat with nextLine in eachLine
if length of nextLine is greater than 0 then
set theText to (nextLine as text)
set AppleScript's text item delimiters to " "
set theTextItems to text items of theText
set AppleScript's text item delimiters to " "
set theText to theTextItems as string
set AppleScript's text item delimiters to {""}
copy (theText as text) to the end of cmykList
end if
end repeat
set chooseList to choose from list cmykList
不過還是很好奇,爲什麼發生這種情況在第一地點。