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
Solved

session variable restore special characters visual basic

Posted on 2014-07-28
7
369 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 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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…

837 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