Announcement

Collapse

Forum Guidelines

This forum is for finished source code that is working properly. If you have questions about this or any other source code, please post it in one of the Discussion Forums, not here.
See more
See less

converse of DecodeCGI

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • converse of DecodeCGI

    useful for creating cgi strings

    Code:
    '------------------------------------------------------------------------------
    ' EncodeCGI encodes string characters to special characters for a CGI string.   
    ' (the reverse of function DecodeCGI found in pbcgi.inc)
    '
    FUNCTION EncodeCGI(s AS STRING) AS STRING
      LOCAL i AS LONG     
      LOCAL temp AS STRING
      
      temp=s
        
        ' first replace the % 
        REPLACE "%" WITH "%25" IN temp
        
        ' replace everything else 
        FOR i = 32 TO 47      
          IF i <> 37 THEN ' %
            REPLACE CHR$(i) WITH "%"+HEX$(i) IN temp
          END IF  
        NEXT   
        
        FOR i = 58 TO 64      
          REPLACE CHR$(i) WITH "%"+HEX$(i) IN temp
        NEXT 
        
        FOR i = 94 TO 96      
          REPLACE CHR$(i) WITH "%"+HEX$(i) IN temp
        NEXT  
        
        FOR i = 123 TO 126      
          REPLACE CHR$(i) WITH "%"+HEX$(i) IN temp
        NEXT  
      
        FUNCTION= temp
    
    END FUNCTION
Working...
X