Solved

session variable restore special characters visual basic

Posted on 2014-07-28
7
370 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
[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
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 33

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
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 33

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

735 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