Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting rid of non-printable junk
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00241748
Message ID:
00241774
Views:
16
>>Does anyone know a simple command to get rid of all non-printable characters from a field. I have a nomenclature field and the user has been entering some carriage returns, tabs, and control characters (inadvertantly) Is there a way that I can get rid of those characters and leave the alpha numeric printable stuff. I know I can do a loop reading every character and checking for its ascii value, but what I was looking for was a function that can be used in a replace statement. TIA
>
>The easiest thing to do would be to create a string containing all characters you want filtered from the file, and then do the following
>
>* I assume that cFilteredChars contains the list of characters to remove
>* and cFld is the field to be stripped
>REPLACE ALL cFld WITH CHRTRAN(cFld,cFilteredChars,'')
>
>putting together the list should require a little work; essentially, if only standard printed ASCII characters were acceptable, then you could build cFilteredChars at least in part using:
>
>
cFilteredChars = ''
>LOCAL i
>FOR i = 0 TO 31 && characters below " " are Control characters
>   cFilteredChars = cFilteredChars + CHR(i)
>ENDFOR
>FOR i = 128 TO 255 && high-order bit set is bad
>   cFilteredChars = cFilteredChars + CHR(i)
>ENDFOR
>
>You could then concatenate any others you want to strip.

Thanks Ed. I will run some tests and see if I can get this implemented.
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Reply
Map
View

Click here to load this message in the networking platform