This fun little script displays all ASCII Characters in a display dialogue.
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set i to 255
set p to 0
set l to {}
repeat with x from 1 to i
try
set p to p + 1
set l to l & ¬
p
on error
set l to l & ¬
" "
end try
end repeat
set u to ""
set r to 0
repeat with y from 1 to (count l)
try
set r to r + 1
set q to item r of l
set u to u & ¬
(ASCII character q) & ¬
" "
on error
set u to u & ¬
" "
end try
end repeat
set h to items 150 through 152 of u as list
display dialog u & "
" with title "ASCII Characters" buttons {(ASCII character 240)}
Fun!
But your script is wildly inefficient.
Here is a slimmed down version
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set u to ""
repeat with x from 32 to 255 -- start at 32, all characters below are non-printing & control codes
try
set u to u & (character id x) & " "
on error
set u to u & " "
end try
end repeat
-- set h to items 150 through 152 of u as list -- not sure what this did?
display dialog u & "" with title "UTF8 Characters" buttons {(character id 63743)}
…and here is a version that skips over all non-printing character codes
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
set u to ""
set x to 32 -- chars 0 to 31 are control codes (i.e. invisible)
repeat until x > 255
try
set u to u & (character id x) & " "
on error
set u to u & " "
end try
set x to x + 1
if x = 127 then set x to 160 -- chars 127 to 159 are more control codes (i.e. invisible)
end repeat
display dialog u & "" with title "UTF8 Characters" buttons {(character id 63743)}