Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

session variable restore special characters visual basic

Posted on 2014-07-28
7
Medium Priority
?
391 Views
Last Modified: 2014-07-29
Hello I'm using session variables passed in a URL like this:

http://xxx.xxx.xxx.xxx/file.asp?var=básicas

Open in new window


   like you see has spanish accents now when you navigate the browser chages to this:

http://xxx.xxx.xxx.xxx/file.asp?var=b%C3%A1sicas

Open in new window


Now using in visual basic to query the string:

var = Request.QueryString("var")
Response.Write(var)

Open in new window


I have this results:

"básicas"

like you see is not "básicas"

   How can I query the string to have full "básicas" inside visual basic to put If then else conditions and more things?

   Of course we just have access real to the resulting variable session because we can't modify the source that send that links with that session variables because of that we just depend on destination visual basic query process. What code is needed to place in the visual basic script with examples?
Thank you
0
Comment
Question by:coerrace
7 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40225652
To be clear this encoded url parameters and nothing to do with session variables

What is your code that is decoding the url param because %C3%A1 correctly translates to á
0
 
LVL 34

Accepted Solution

by:
Big Monty earned 1000 total points
ID: 40225653
The url is being encoded, unfortunately there is no built in decode function, so you will have to use a custom function:

' URL decode to retrieve the original value

Function URLDecode(sConvert)
    Dim aSplit
    Dim sOutput
    Dim I
    If IsNull(sConvert) Then
       URLDecode = ""
       Exit Function
    End If

    ' convert all pluses to spaces
    sOutput = REPLACE(sConvert, "+", " ")

    ' next convert %hexdigits to the character
    aSplit = Split(sOutput, "%")

    If IsArray(aSplit) Then
      sOutput = aSplit(0)
      For I = 0 to UBound(aSplit) - 1
        sOutput = sOutput & _
          Chr("&H" & Left(aSplit(i + 1), 2)) &_
          Right(aSplit(i + 1), Len(aSplit(i + 1)) - 2)
      Next
    End If

    URLDecode = sOutput
End Function

Open in new window

0
 

Author Comment

by:coerrace
ID: 40225682
Thank you for answer i used your function like this:

strPath = Server.URLEncode(raceplan)
Response.write(strPath)

Open in new window



And i have like result:

"b%C3%A1sicas" without quotes

And if there are spaces fill with "+" without quotes

Not give real result how can we use that in one if then else condition? or why not give the real result.
Thank you
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 34

Expert Comment

by:Big Monty
ID: 40225690
You want to use the decode function I posted
0
 

Author Comment

by:coerrace
ID: 40225707
I'm using your function like:

strPath = URLDecode(var)

Open in new window

and the spaces are ok now but the special character like "á" (without quotes) in other words i have this result:

"básicas" without quotes

   In long names with spaces the spaces are fixed like i said you but not other characters like I mentioned. Any solution for special characters?
Thank you
0
 
LVL 54

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 1000 total points
ID: 40225988
I wonder if you have set your code page

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

Open in new window

and some form of
 <meta charset="utf-8">

Open in new window


Ray's article is for the PHP topic, but relevant for ASP as well
http://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_11880-Unicode-PHP-and-Character-Collisions.html
0
 

Author Closing Comment

by:coerrace
ID: 40226889
Thank you
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

Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
Suggested Courses

824 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