Solved

session variable restore special characters visual basic

Posted on 2014-07-28
7
358 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 32

Accepted Solution

by:
Big Monty earned 250 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 32

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 52

Assisted Solution

by:Scott Fell, EE MVE
Scott Fell,  EE MVE earned 250 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
"In order to have an organized way for empathy mapping, we rely on a psychological model and trying to model it in a simple way, so we will split the board to three section for each persona and a scenario and try to see what those personas would Do,…
The viewer will learn how to dynamically set the form action using jQuery.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now