Replace the while loop with this:
while (%i < 256) {
if ($chr(%i) !isalnum) did -a $dname 1 $ifmatch
inc %i
}
Over here it still shows a lot of black boxes, but I suppose you want those in because they could be valid characters depending on the font used.