[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Convert a Perl CGI code to ASP

Posted on 2004-10-22
6
Medium Priority
?
353 Views
Last Modified: 2010-08-05
I need to convert a Perl CGI script to ASP vb script, becuase I require to convert the data into my ASP program. and I have no idea about the CGI.

This is the CGI script

sub dc_decode {
    my $todecode = shift;
    return undef unless defined($todecode);
    $todecode =~ tr/+/ /;       # pluses become spaces
    $todecode =~ s/%([0-9a-fA-F]{2})/pack("c",hex($1))/ge;
    $todecode =~ s/\r\n/\n/g;;
    return $todecode;
}

Do anyone know the ASP version of the above script?
0
Comment
Question by:billson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 1500 total points
ID: 12387606
in VBScript you can use the UnEscape() function for this.

<%
MyVar = Unescape(Myvar)
%>

But maybe you don't have to use this function at all. The perl function is used to convert a (url-encoded) querystring into something that was originally posted. I don't know in what context you need to use it, but in ASP, the querystring is automatically urldecoded when you ask individual items of the Request object.

So you will need to decode if you use the complete querystring

<%
Response.write Unescape(Request.Quersystring)
%>

But you don't need to decode for each formfield:

<%
Response.write Request.Querystring("fieldname")
%>

0
 
LVL 13

Expert Comment

by:StormyWaters
ID: 12389204
Here is another alternative:
http://flangy.com/dev/asp/urldecode.html
0
 
LVL 1

Author Comment

by:billson
ID: 12392080
thx sybe  and StormyWaters, the return code is correctly display in ASP page, but if I use Windows Script Hosting - vbs file to get the output. the return code is mess-up. Any idea?
0
 
LVL 28

Expert Comment

by:sybe
ID: 12392093
What is the input you are giving to the Windows Scripting Host?
0
 
LVL 1

Author Comment

by:billson
ID: 12394523
I have inputed Chinese character (BIG5 character set) and use the following script to encode in WSH, ASP also. ASP can return what I inputed. But WSH just return the "??" for those chinese character. I am using WinXP Chinese Traditional Version.

Since I need to convert 10000 message to the new asp system. I prefer to use WSH to prevent ASP timeout. But if no solution for WSH, I will try to use ASP to do so.

Function URLEncode(Text)
    Dim acode
    Temp = ""
    For i = Len(Text) To 1 Step -1
        acode = Asc(Mid(Text, i, 1))
            if (acode >= 48 AND acode <= 57) OR (acode >= 65 AND acode <= 90) OR (acode >= 97 AND acode <= 122) then
                  Temp = Mid(Text, i, 1) & Temp
            elseif acode = 32 then
                  Temp = "+" & Temp
            else
                  Temp = "%" & Hex(acode) & Temp
            end if
    Next
      URLEncode = Temp
End Function
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question