New call-to-action
Results 1 to 7 of 7

Thread: Remove unprintable ascii values

  1. #1
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Remove unprintable ascii values

    I often deal with data extracted from other systems which I then manipulate in Alpha. I recently found a need to strip out non-printable ascii codes from this data that caused stritran() to stumble. This function substitutes a space character for ascii codes " 32 and " 126, preserving line position sequence of printable characters.

    FUNCTION blank_noprint AS C (Input_String AS C )
    If input_string = ""
    end
    End if
    cblob = char_to_blob(Input_String)
    Output_string = ""
    For i = 1 to cblob.size()
    Output_String = Output_String + if(between(asc(cblob.peekc(i,1)),32,126),cblob.peekc(i,1)," ")
    Next i
    blank_noprint = Output_String
    END FUNCTION

  2. #2
    VAR
    Real Name
    Martin W. Cole
    Join Date
    Apr 2000
    Location
    Terrell, Texas (near Dallas)
    Posts
    5,963

    Default RE: Remove unprintable ascii values

    Stan, this is a terrific idea for a function. I have many times had data come in with carriage returns and line feeds embedded. Is your use of using a blob and peek because it is faster?

  3. #3
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Remove unprintable ascii values

    I worked with the blob functions because the stritran() and similar would not function on the whole of a string containing some embedded non-printable ascii codes. Rather than using a hex editor to diagnose the problem I found that they did not cause the same problem when parsed singly from a blob.

    -- if that makes any sense

    As usual I only tested the function on the data I was working with at the time and the function is worth very little more than what it costs you.

    Glad you may find it of some use.

  4. #4
    "Certified" Alphaholic Melvin Davidson's Avatar
    Real Name
    Melvin Davidson
    Join Date
    Apr 2000
    Location
    Parker, CO
    Posts
    1,197

    Default RE: Remove unprintable ascii values

    FYI,

    I employed a similar technique to help clean up memo fields.
    Only diff was I had to write / and read back from a file.

    Posted as Memo Field Repair scripts in this same forum.

  5. #5
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Remove unprintable ascii values

    I seem to recall that and it was probably the inspiration for my effort without my clearly remembering it. Thanks.

  6. #6
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: Remove unprintable ascii values

    While studying some other code from the archive I noticed that Jim Chapman used the string-to-blob-to-string technique as well in his excellent Compare two databases for differences script. Thanks to both of you for the insight.

  7. #7
    Member Mike Thomson's Avatar
    Real Name
    Mike Thomson
    Join Date
    Jul 2005
    Location
    Queensland, Australia
    Posts
    266

    Default RE: Remove unprintable ascii values

    Hi Stan,

    I use base64encode() to do this

    You can then use base64decode() to convert it back again

    regards,

    Mike

Similar Threads

  1. Remove Filter ?
    By Newton Thomas in forum Alpha Five Version 5
    Replies: 9
    Last Post: 11-24-2004, 06:10 AM
  2. remove all but numerics
    By martinwcole in forum Alpha Five Version 5
    Replies: 2
    Last Post: 11-20-2003, 03:18 PM
  3. Remove toolbars
    By Edward F. Schulz in forum Alpha Five Version 4
    Replies: 3
    Last Post: 04-11-2002, 12:03 PM
  4. Previous values lookup unique values only
    By Greg Fong in forum Alpha Five Version 4
    Replies: 3
    Last Post: 02-01-2002, 02:47 PM
  5. ASCII Values
    By Tom Patten in forum Alpha Five Version 4
    Replies: 14
    Last Post: 12-28-2001, 04:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •