我有一个简单的代码将文本文件读入列表中。它是这种格式的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
不过还是很好奇,为什么发生这种情况在第一地点。