I have a simple function which will return a string with all non-allowed characters stripped from it.
function cleanASCII pString, pModeList, pCustomList /* pModeList is a comma delimited list that may contain the following values: "lowercase,uppercase,numbers,tabs,newlines,returns,spaces,symbols,custom" If custom is used, then a third paramaeter containing allowed characters must be supplied. */ if pModeList is empty then put " 0-9a-zA-Z" into tAllowedChars end if repeat for each item pMode in pModeList put word 1 of pMode into pMode switch break case "tabs" is in pMode put "\t" after tAllowedChars break case "newlines" is in pMode put "\n" before tAllowedChars break case "returns" is in pMode put "\r" before tAllowedChars -- currently not working break case "spaces" is in pMode put " " after tAllowedChars break case "numbers" is in pMode put "0-9" after tAllowedChars break case "lowercase" is in pMode put "a-z" after tAllowedChars break case "uppercase" is in pMode put "A-Z" after tAllowedChars break case "symbols" is in pMode put "!#$%&'()*+,./:;<=>?@[\\_`{|}~^-" after tAllowedChars break case pMode is "custom" put pCustomList after tAllowedChars break end switch end repeat put "[" & tAllowedChars & "]" into tMatchText repeat for each character theChar in pString if matchtext(theChar, tMatchText) is true then put theChar after cleanString end if end repeat return cleanString end cleanASCII Bob S > On Jan 12, 2018, at 16:48 , David Epstein via use-livecode > <use-livecode@lists.runrev.com> wrote: > > I use “the number of words in myString = 0” to test whether a line of text > appears empty, since I want a line with only space characters to be > understood as empty. > But a line of text I pasted from elsewhere contained an invisible character > whose charToNum value is 202, and this was counted as a word by my script. > Is there a better way to test for a line of text that has no visible > characters? > Many thanks. > > David Epstein _______________________________________________ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode