On Jul 31, 2007, at 11:37 AM, MB Software Solutions wrote:

>> Does anyone know of an easy way to strip off any non-ACSII  
>> characters from a
>> string?
>>
>> Bill
>>
> Ed Leafe had posted such a code sample awhile back using STRTRAN.  You
> might check the archives for it.  I can't recall it off the top of my
> head.  That's something I always need to consult the Hacker's Guide  
> for
> syntax.  ;-)

        Basically, the idea is to define the good characters, and use  
STRTRAN on the original string to remove the good characters. That  
leaves all the bad characters, right? Now run STRTRAN against the  
original string with the bad chars; all that will be left is the good  
chars. In code:

LPARAMETERS targetStr
* We want only chars < 128
good = ""
FOR ii = 1 TO 127
        good = good + CHR(ii)
ENDFOR
bad = STRTRAN(targetStr, good)
IF EMPTY(bad)
        ret = targetStr
ELSE
        ret = STRTRAN(targetStr, bad)
ENDIF
RETURN ret

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com




_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to